OJ-Problems-Source/CodeVS/1475_冰封.c

23 lines
430 B
C
Raw Normal View History

2016-07-06 14:28:18 +08:00
/*
:
:p1475 m进制转十进制
*/
#include <stdio.h>
#include <string.h>
int get(int a){
return a >= 'A' && a <= 'Z' ? a - 'A' + 10 : a - '0';
}
int main(int argc, char* argv[]) {
int b, i, j, out = 0;
char a[100];
scanf("%s%i", a, &b);
for(i = 1, j = strlen(a) - 1; j >= 0; i *= b, j--)
out += get(a[j]) * i;
printf("%i",out);
if(argc > 1) for(;;);
return 0;
}