请高手点化!!!!!!!!!
请高手点化!!!!!!!!!
我的题目是随意输入一个数,转化成二进制:
我编出了,可是却不能到过来:举个例子:
输入:28
00011
而不是:
11000
那个高手能点化一下: ![](images/smilies/emot/em03.gif)
![](images/smilies/emot/em03.gif)
我的代码如下: #include <iostream.h>
int suan(unsigned int x) {
while(x!=1) {
if(x%2==0) cout<<0; else cout<<1; x=x/2;
} return x;
}
void main() { unsigned int n; int z;
cin>>n; z=suan(n); cout<<z<<endl;
} 我试过了.我还没那水平,你能帮忙续写出来么?