fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string s;
  6. cin >> s;
  7. for (char c : s) {
  8. int n = c - '0';
  9. bool k = n % 2;
  10. for (int i = 1; i <= n; ++i) {
  11. for (int j = 1; j <= (k ? n : i); ++j)
  12. cout << " " << j;
  13. cout << endl;
  14. }
  15. cout << endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0s 3472KB
stdin
245
stdout
 1
 1 2

 1
 1 2
 1 2 3
 1 2 3 4

 1 2 3 4 5
 1 2 3 4 5
 1 2 3 4 5
 1 2 3 4 5
 1 2 3 4 5