首页 > 其他分享 >进制转换

进制转换

时间:2022-10-07 23:13:18浏览次数:33  
标签:count 转换 进制 int printf Enter

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

}
`


标签:count,转换,进制,int,printf,Enter
From: https://www.cnblogs.com/yang-ziran/p/16760465.html

相关文章