您的位置:首页 > 其它

2017.8.16. 任意进制转十进制

2017-08-16 11:55 218 查看

任意进制转十进制

适用范围:某些计算题

std.cpp

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

int n,m;
char s[55];
int check(char x)
{
if(isdigit(x))return x-'0';
else return x-55;
}

int main()
{
cin >> n;
scanf("%s",s);

int len = strlen(s);
for(int i=0;i<len;i++)
m = check(s[i]) + n * m;

cout << m;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: