Advertisement
DidiMilikina

13. Number Pyramid

Oct 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int number;
  6.     cin >> number;
  7.  
  8.     int current_num = 1;
  9.     int row = 1;
  10.     while (current_num <= number)
  11.     {
  12.         for (size_t i = 0; i < row; i++)
  13.         {
  14.             if (current_num > number)
  15.             {
  16.                 break;
  17.             }
  18.             cout << current_num << " ";
  19.             current_num++;
  20.         }
  21.         row++;
  22.         cout << endl;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement