原
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
/** 讲m进制的数n转换为十进制数 */#include#include#include#includeusingnamespacestd; int transToNum(char a) {if(isdigit(a)) {return a -'0'; }elseif (isalpha(a)) {return a -'A' +10; }else {return0; } } int main() {char buf[32];cin.getline(buf,64);char num[24];int m;sscanf(buf,"%s %d", num, &m);int sum =0;//记录输入数的十进制数int len_num =strlen(num);for(int i =0; i