简单进制转化
int change(int x, int ch)
{
int tmp = x;
int bit[10] = {0};
char everybit[5] = {'A', 'B', 'C', 'D', 'E'};
int count = 0;
while(tmp != 0) // 辗转相除法求对应进制
{
bit[count] = tmp % ch;
//printf("%d\n", bit[count]);
tmp = tmp / ch;
count ++;
}
int i;
for(i = count - 1; i >= 0; i --) // 倒序输出对应的值
{
if(bit[i] >= 10)
printf("%c", everybit[bit[i] - 10]);// 十进制以上符号转换
else
printf("%d", bit[i]);
}
printf("\n\n");
}
—