#include<stdio.h>
int main()
{
int n,a[30],t,f,i,c,j;
c=0;
f=0;
t=0;
j=0;
scanf("%d",&n);
a[0]=n;
i=0;
while(a[i]!=1&&a[i]!=0)
{
if(a[i]<0)
{
t=t*10+(-a[i]+2)%2;
a[i+1]=(-a[i]+1)/2;
}
else
{
t=t*10+a[i]%(-2);
a[i+1]=a[i]/(-2);
}
i=i+1;
c=c+1;
}
t=t*10+a[i];
c=c+1;
while(t>0)
{
f=f*10+t%10;
t=t/10;
j=j+1;
}
while(j!=c)
{
j=j+1;
f=f*10;
}
printf("%d",f);
return 0;
}
[ New Thread ]
Problem 1136 >> 错误%36,求大佬看看哪里还有问题 |
201903150208 @ 2019-12-08 12:32:24
|