Advertisement
Maku779

CCS1203_A2_Asterisk_Pyramid

Dec 7th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int space, rows;
  6.     char dw;
  7.     do
  8.     {
  9.         system("cls");
  10.         cout << "Enter number of rows: ";
  11.         cin >> rows;
  12.         cout<<endl;
  13.         for (int i = 1, k = 0; i <= rows; ++i, k = 0)
  14.         {
  15.             for (space = 1; space <= rows - i; ++space)
  16.             {
  17.                 cout << "  ";
  18.             }
  19.             while (k != 2 * i - 1)
  20.             {
  21.                 cout << "* ";
  22.                 ++k;
  23.             }
  24.             cout << endl;
  25.         }
  26.         cout << "\nTry again?[Y/N]: ";
  27.         cin >> dw;
  28.     } while (dw == 'Y' || dw == 'y');
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement