进制的转化
#include <stdio.h>
int main(){
int num;
printf("请输入数字:");
scanf("%d",&num);
int jinzhi = 16;
//二进制
int wei = 1;
long long sum = 0;
while(1){
//取余 10100
// 00101
// 1*0 + 10*0 + 100*1 + 1000*0 + 10000*1
// 10100
int yu = num % jinzhi;
num = num / jinzhi; //10 5
//目前的总和:当前位数的值 + 之前的值
sum = sum + yu * wei;//0
wei = wei * 10 ;//1*10 100 1000
if(num < jinzhi){
sum = sum + num * wei;
break;
}
}
printf("%d\n", sum);
return 0;
}