用C语言实现进制转换程序,转换为二进制,八进制,十六进制
(我还不太会编写这样的程序,在网上查找了相关资料)
参考https://blog.csdn.net/qq_41877184/article/details/88753144
`#include <stdio.h>
int main()
{
int x,p;
printf("Enter the new base:");
scanf("%d",&p);
printf("Enter the number to be converted:");
scanf("%d",&x);
printf("The answer is:");
int a[100];
int count=0;
do{
a[count++]=x%p;
x=x/p;
}while(x!=0);
for(int i=count-1;i>=0;i--){
printf("%d",a[i]);
}
return 0;
}
`