Pay attention to the case of 0, if you don't write the judgment, you can't output it.
#include <iostream> using namespace std; intmain() { int a, b, d; cin >> a >> b >> d; int num = a + b; int c[1001]; int k = 0; if(num == 0) { cout << "0"; return 0; } while(num) { c[k++] = num % d; num = num / d } for(int i = k - 1; i >= 0; i--) { cout << c[i]; } return 0; }