- 方法1(代码附上,暂时未行通,有兴趣可以修改一下)
- #include <stdio.h>
int dectobe(int n)
{
int temp=n;
int k=1;
int result=0;
int i;
while(temp)
{
i=temp%2;
result=k*i+result;
k=k*10;
temp=n/2;
printf("%d\n",result);
}
printf("%d\n",result);
return result;
}
int main(int argc, char const *argv[])
{
int n=15;
int result;
//printf("input number\n");
//scanf("%d",&n);
//getchar();
result=dectobe(n