Advertisement
kolioi

Number pyramid C++

Jul 16th, 2018
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin >> n;
  7.  
  8.     int num = 1, col = 1, max_col = 1;
  9.     while (num <= n)
  10.     {
  11.         cout << num++;
  12.         if (++col > max_col)
  13.         {
  14.             cout << endl;
  15.             col = 1;
  16.             max_col++;
  17.         }
  18.         else
  19.             cout << ' ';
  20.     }
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement