c语言编程问题求大佬

2024-11-03 09:53:53
推荐回答(1个)
回答1:

#include
void dec2n(int x,int n)
{if(x>=n)dec2n(x/n,n);
printf("%ld",x%n);
}
int main()
{
int x;
long int n=2,m=8;
scanf("%d",&x);
printf("%d的%d进制为:\n",x,n);
dec2n(x,n);
printf("\n");
printf("%d的%d进制为:\n",x,m);
dec2n(x,m);
printf("\n");
return 0;
}