enkov

Пирамида с двойни цикли

Oct 23rd, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include "stdafx.h"  // само при Visual Studio <= 2017
  2. #include <iostream>
  3. #include <ctime> // заради time()
  4. using namespace std;
  5.  
  6. //C++ program to display half star pyramid
  7.  
  8. #include <iostream>
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     int n, i, j;
  14.  
  15.     cout << "Enter number of rows: ";
  16.     cin >> n;
  17.  
  18.     for (i = 1; i <= n; i++)
  19.     {
  20.         for (j = n - i; j >= 0; j--)
  21.             cout << " ";
  22.         for (j = 1; j <= i; j++)
  23.             cout << "* ";
  24.         cout << "\n";
  25.     }
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment