1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include<iostream> using namespace std;
int getNum1(int x, int y) { return x / y; }
int getNum2(int x, int y) { return x % y; }
int main() {
int n; cin >> n; int m = n; int count = 1;
while (getNum1(n, 10)) { n = getNum1(n, 10); count++; }
int* p = new int[count];
for (int i = 0; i < count; i++) { *(p + i) = getNum2(m, 10); m = getNum1(m, 10); } for (int k = count - 1; k > 0; k--) { cout << *(p + k) << " "; } cout << *p;
delete[]p;
return 0; }
|