输入一个m进制的n,将n转换成十进制的数并输出。
#include<iostream>
#include<stack>
using namespace std;
int main()
{
stack<int> s;
int n,m;
while(cin>>n>>m)
{
if(n==0)
cout<<"0"<<endl;
else
{
while(n>0)
{
s.push(n%m);
n=n/m;
}
}
while(!s.empty())
{
cout<<s.top();
s.pop();
}
cout<<endl;
}
return 0;
}