题解 | #又一版 A+B#
又一版 A+B
https://www.nowcoder.com/practice/9255c05d45b8406c9b588d7c57aa920b
#include <iostream> #include <algorithm> using namespace std; //把10进制数x转换为m进制数 void func(long long x, int m) { if (x == 0) cout << 0 << endl; else { string s; while (x) { s += '0' + x % m; x /= m; } reverse(s.begin(), s.end()); cout << s << endl; } } int main() { int m, a, b; while (cin >> m >> a >> b && m) { func(a + b, m); } return 0; }