C语言 进制转换

void scale1(int scanfNum){

int i=0;

int newNums[64];

while (scanfNum>0) {

newNums[i++]=scanfNum%2;

scanfNum /= 2;

}

printf("十进制转二进制数据为:0x");

for(i=i-1;i>=0;i--){

printf("%d",newNums[i]);

};

}

·········································································································································

void scale2(int scanfNum){

char nums[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

int newNums[100];

int i=0;

int n = 0;

while (scanfNum>0) {

newNums[i++] = scanfNum%16;

scanfNum/=16;

}

printf("十进制转十六进制数据为:0x");

for (i=i-1; i>=0; i--) {

n =newNums[i];

printf("%c",nums[n]);

}

}


C语言 进制转换_第1张图片

你可能感兴趣的:(C语言 进制转换)