用C语言实现下面伪代码描述的进制转换程序,提交运行结果截图,至少三张,包含转换为二进制,八进制,十六进制的截图
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int newBase,num;
int decimalNumber,quo,remainder,answer;
printf("Enter the number to be converted:");
scanf("%d\n",&decimalNumber);
printf("newBase:");
scanf("%d\n",&newBase);
quo=1;
num=1;
answer=0;
while(quo!=0)
{
quo=decimalNumber/newBase;
remainder=decimalNumber%newBase;
answer=answer+remainder*num;
num=num*10;
decimalNumber=quo;
}
printf("The answer is:%d",answer);
return 0;
}
标签:进制,int,代码,转化,num,newBase,answer,quo,decimalNumber From: https://www.cnblogs.com/liudi20221408/p/16774043.html