大家帮忙找一下错误
帮忙看一下 我自己写的代码 但运行出错了 找不到错误的源头……#include<iostream>
#include<stack>
#include<math.h>
#include<string>
using namespace std;
class scale
{
private:
int m;
string str;
public:
scale(string &pt,int &j):str(pt),m(j){}
int translate_ten()
{
int tmp=0;
int i,j;
for( i=0,j=str.size();i<j;++i)
{
if(str[i]>='A'&&str[i]<='F')
tmp+=(str[i]-'A'+10)*pow(m,j-i-1);
if(str[i]>='0'&&str[i]<='9')
tmp+=(str[i]-'0')*pow(m,j-i-1);
}
return tmp;
}
~scale(){}
};
void translate_m(int &tmp,int &m)
{
int t;
stack <char> M;
while(tmp)
{
t=tmp%m;
if(t<10)
M.push(t);
else
{
t=t-10+'A';
M.push(t);
}
tmp/=m;
}
while(!M.empty())
{
printf("%c",M.top());
M.pop();
}
}
void main()
{
int m;
int result;
scanf("%d",&m);
if(m<2||m>16)
return;
string num1,num2;
scanf("%s%s",&num1,&num2);
scale t1(num1,m);
scale t2(num2,m);
result=t1.translate_ten()/t2.translate_ten();
translate_m(result,m);
printf("\n");
result=t1.translate_ten()%t2.translate_ten();
translate_m(result,m);
}