SHARE
TWEET

Number pyramid C++

kolioi Jul 16th, 2018 220 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top