题解 | #又一版 A+B#
又一版 A+B
http://www.nowcoder.com/practice/9255c05d45b8406c9b588d7c57aa920b
#include<cstdio> using namespace std; int main() { long long A,B; long long sum ; int m; while(scanf("%d %lld %lld",&m,&A,&B)!=EOF && m != 0) { int a[32]; int p = 0; sum = A+B; if(sum == 0) { printf("0\n"); } else { while(sum !=0) { a[p] = sum % m; sum = sum / m; p++; } } for(int i = p-1;i>=0;i--) { printf("%d",a[i]); } } }