回复 4楼 beyondyf
如果非要用递归呢,这段代码有什么问题
#include<stdio.h>
void TenToBi(int a,int i);
int main(){
int b,i=0;
printf("please input the number you want to transform:\n");
scanf("%d",&b);
TenToBi(b,i);
}
void TenToBi(int b,int i){
int d,e,sb[32]={0};
if(i<=31){
d=b/2;
e=b%2;
sb[i]=e;
i++;
TenToBi(d,i);
}
else{
for(i=31;i>=0;i--)
printf("%d",sb[i]);
}
}