又一版 A+B

http://acm.hdu.edu.cn/showproblem.php?pid=1877

View Code
 1 #include<iostream>
 2 using namespace std;
 3 
 4 void change(int m,int a)
 5 {
 6     int s[20]={0};
 7     int i=0;
 8     while(a)
 9     {
10         s[i++]=a%m;
11         a=a/m;
12     }
13     while(i)
14         cout<<s[--i];
15     cout<<endl;
16 }
17 
18 int main()
19 {
20     int m,a,b;
21     while(cin>>m,m)
22     {
23         cin>>a>>b;
24         a=a+b;
25         if(a==0)
26             cout<<0<<endl;
27         else
28             change(m,a);
29     }
30     return 0;
31 }

 

posted on 2012-06-30 12:42  可笑痴狂  阅读(444)  评论(0)    收藏  举报