信息系统项目管理师_2024年软考学习应考交流_信息系统项目管理师考试

 找回密码
 马上注册

QQ登录

只需一步,快速开始

查看: 3968|回复: 0
打印 上一主题 下一主题

Google面试的一道题目及解答

[复制链接]

该用户从未签到

跳转到指定楼层
楼主
发表于 2006-4-25 09:20:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
<span id="post1" style="FONT-SIZE: 12px; COLOR: #000000;">题目如下:<br/><br/>题目:解答下面的隐藏等式,其中的M和E的值可以互换,但不允许第一位是0。<br/>WWWDOT - GOOGLE = DOTCOM <br/><br/>解答代码:<br/>/*******************************/ <br/>/* &nbsp; Q:WWWDOT-GOOGLE=DOTCOM &nbsp;*/ <br/>/* &nbsp; A:777589-188103=589486 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/ <br/>/* &nbsp; &nbsp; 777589-188106=589483 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */ <br/>/*******************************/ <br/><br/><br/>#include &lt;stdio.h&gt; <br/><br/>void getans(int num[], int n_tmp) &nbsp; &nbsp;//通过递归调用对num_0_9数组进行组合排序 <br/>{ <br/>&nbsp;int tmp; <br/>&nbsp;int w,d,o,t,g,l,e,c,m,wwwdot,google,dotcom; <br/>&nbsp;if(n_tmp == 1){ <br/>&nbsp; &nbsp;w = num[0]; <br/>&nbsp; &nbsp;d = num[1]; <br/>&nbsp; &nbsp;o = num[2]; <br/>&nbsp; &nbsp;t = num[3]; <br/>&nbsp; &nbsp;g = num[4]; <br/>&nbsp; &nbsp;l = num[5]; <br/>&nbsp; &nbsp;e = num[6]; <br/>&nbsp; &nbsp;c = num[7]; <br/>&nbsp; &nbsp;m = num[8]; <br/>&nbsp; &nbsp;wwwdot = w*111000 + d*100 + o*10 + t; <br/>&nbsp; &nbsp;google = g*100100 + o*11000 + l*10 + e; <br/>&nbsp; &nbsp;dotcom = d*100000 + o*10010 + t*1000 + c*100 + m; <br/><br/>&nbsp; &nbsp;//其中的M和E的值可以互换,但不允许第一位是0。 <br/>&nbsp; &nbsp;if(w!=0 &amp;&amp; g!=0 &amp;&amp; d!=0) &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp;if((wwwdot - google == dotcom) || (wwwdot - (google - e + m) == (dotcom - m + e))) <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf("%d - %d = %d\n",wwwdot,google,dotcom); <br/>&nbsp;} <br/>&nbsp;else{ <br/>&nbsp; &nbsp;for(int i = 0; i &lt; n_tmp; i++){ <br/>&nbsp; &nbsp; &nbsp;tmp=num; num=num[n_tmp-1]; num[n_tmp-1]=tmp; <br/>&nbsp; &nbsp; &nbsp;getans(num, n_tmp-1); <br/>&nbsp; &nbsp; &nbsp;tmp=num; num=num[n_tmp-1]; num[n_tmp-1]=tmp; <br/><br/>&nbsp; &nbsp;} <br/>&nbsp;} <br/>} <br/><br/>void main() <br/>{ <br/>&nbsp;int n = 10; <br/>&nbsp;int num_0_9[]={0,1,2,3,4,5,6,7,8,9}; <br/><br/>&nbsp;getans(num_0_9, n); <br/><br/>} <br/></span>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 顶 踩
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

小黑屋|手机版|Archiver|信息系统项目管理师_软考交流平台. ( 鄂ICP备11002878号-1  公安备案号:42011102001150

GMT+8, 2025-7-5 07:35

Software by Discuz! X3.2

© 2001-2013 SKIN BY DSVUE

快速回复 返回顶部 返回列表