#include <stdio.h>
#include <math.h>
void hexto(char hex[]){
unsigned int res = 0;
for(int i = 0; hex[i]!='\0'; i++){
if(hex[i] >= 'a' && hex[i] <= 'f'){
res = res*16 + hex[i]-'a'+10;
}else if(hex[i] >= 'A' && hex[i] <= 'F'){
res = res*16 + hex[i]-'A'+10;
}else{
res = res*16 + hex[i]-'0';
}
}
printf("十六进制书%s=>十进制数%u",hex,res);
}
int main(){
char hex[8];
printf("请输入一个16进制数\n");
scanf("%s",hex);
hexto(hex);
}