#include<iostream>
using namespace std;
int weishu(int n)
{
int count = 1;
while (n /= 10)
count++;
return count;
}
double power(double a, int b)
{
double val = 1;
while (b) {
val *= a;
--b;
}
return val;
}
int Bin_to_Dec(int N,int oc)
{
int n =weishu(oc);
int result = 0;
while (n--)
{
oc =oc%static_cast<int>(power(10, n+1));
result += (oc / power(10, n)) * power(N, n);
}
return result;
}
int main()
{
cout << "请输入你要从( )进制转化为10进制:";
int N,i;
cin >> N;
cout << "\n请输入你要转化为10进制的数:";
cin >> i;
cout<<'\n' <<N<<"进制数\""<<i<<"\"转为十进制数为:"<< Bin_to_Dec(N,i)<<endl;
return 0;
}
```