提交时间:2024-08-19 23:02:05

运行 ID: 168140

#include<iostream> #include<cmath> using namespace std; int main() { int n,a,b,a1=0,b1=0,i=0,c,z[10000]; cin>>n>>a>>b; while(a>0) { a1=a1+a%10*pow(n,i); i++; a=a/10; } i=0; //cout<<"a1="<<a1<<endl; while(b>0) { b1=b1+b%10*pow(n,i); //cout<<"b1="<<b1<<endl; i++; b=b/10; } //cout<<"b1="<<b1<<endl; c=a1+b1; i=0; while(c>0) { z[i]=c%n; c=c/n; i++; } for(int j=i-1;j>=0;j--) { cout<<z[j]; } }