fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin >> n;
  8.  
  9. for (int i = 0; i < n; i++) {
  10. // Print spaces
  11. for (int j = 1; j <= n - i - 1; j++) {
  12. cout << " ";
  13. }
  14.  
  15. // Print numbers
  16. for (int k = 1; k <= i + 1; k++) {
  17. cout << k;
  18. }
  19.  
  20. // Break the line
  21. cout << endl;
  22. }
  23.  
  24. return 0;
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5288KB
stdin
5
stdout
    1
   12
  123
 1234
12345