B진법 수 N이 주어진다. 이 수를 10진법으로 바꿔 출력하는 프로그램을 작성하시오.
10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를 사용한다.
A: 10, B: 11, ..., F: 15, ..., Y: 34, Z: 35
ex1) 10진법

ex2)2진법

#include<stdio.h>
#include<string.h>
int main(){
int n;
char str[1000];
int len, k, num;
int i = 0;
int result = 0;
scanf("%s %d", str, &n);
len = strlen(str);
while (str[i]){
k = i;
if(str[i]>= 'A' && str[i]<='Z'){
num = str[i]-'A'+10;
}
if(str[i]>='0' && str[i]<= '9')
num = str[i]-'0';
while(len-k-1>0){
num = num * n;
k++;
}
result = result + num;
i++;
}
printf("%d", result);
return 0;
}```