joj1006
来源:互联网 发布:只有我知bilibili双语 编辑:程序博客网 时间:2024/06/04 20:18
#include<iostream>using namespace std;int main(){int r,a,b,c,t,i,n;int count,count1 ,count2;int h[1000]={0},m[1000]={0},w[1000]={0};while(cin>>a>>b>>c,a||b||c){count = 0,count1 = 0,count2 = 0;t=b+c;while(b){i=b%a;b/=a;m[count1++]=i; } for(int g=0;g<count1;g++){ cout<<m[count1-g-1];}cout<<" "<<"+"<<" ";while(c){n=c%a;c/=a;w[count2++]=n; } for(int f=0;f<count2;f++){ cout<<w[count2-f-1];}cout<<" "<<"="<<" ";while(t){r=t%a;t/=a;h[count++]=r; } for(int j=0;j<count;j++){ cout<<h[count-j-1];}cout<<endl;}return 0;}