进制转换

用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;

}
`


posted @ 2022-10-07 22:55  20221322杨梓然  阅读(12)  评论(0编辑  收藏  举报