codevs1475m进制转10进制
程序员文章站
2024-01-13 19:59:28
...
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
string n;
int m;
int sum=0;
int main()
{
cin >> n >> m;
for (int i = 0; i < n.length(); ++i)
{
if (n[i] <= '9')
sum += pow(m, n.length() - 1 - i)*(n[i] - 48);
else
sum += pow(m, n.length() - 1 - i)*(n[i] - 55);
}
cout << sum;
return 0;
}
上一篇: java添加超时检测