📄 subject_31635.htm
字号:
<p>
序号:31635 发表者:小防 发表日期:2003-03-06 09:42:55
<br>主题:招聘会上的当场考题
<br>内容:我在招聘会上遇到当场作题,当场入取,我写出来了,但有点烦琐,我想请教一个简单的写法!<BR>“假8进制”就是10进制数没有8和9,权是8,逢8进一,比如123化成10进制为=1*8*8+2*8+3<BR>做一个字例程,把一个int数(8进制)转化为10进制,谢谢!
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:罗兹维尔 回复日期:2003-03-06 16:50:14
<br>内容:#include<iostream.h><BR><BR>int tran(int num);<BR><BR>void main()<BR>{<BR> int num;<BR> cout<<"input a number:";<BR> cin>>num;<BR> num=tran(num);<BR> if(num==-1)<BR> cout<<"input is not a right num"<<endl;<BR> else<BR> cout<<"result is"<<num<<endl;<BR>}<BR><BR> <BR>int tran(int num)<BR>{<BR> int temp1,temp2=0,i=0,j;<BR> do{<BR> temp1=num%10;<BR> if(temp1>=8) return -1;<BR> j=i;<BR> while(j!=0)<BR> {<BR> temp1*=8;<BR> j--;<BR> }<BR> temp2+=temp1;<BR> num=num/10;<BR> i++;<BR> }while(num!=0);<BR> return temp2;<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -