Advertisement
zakisu

Piramida Bintang

Sep 21st, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int rows;
  6.     cout << "Enter number of stars: ";
  7.     cin >> rows;
  8.     for(int i = 0; i < rows; i++)
  9.     {
  10.         for(int space = 1; space <= rows-i; space++){
  11.             cout <<"  ";
  12.         }
  13.         for(int j = 0; j <= i; j++)
  14.         {
  15.             if(j == 0){
  16.                 cout << "*" << "   ";
  17.             } else if (j == i) {
  18.                 cout << "*" << "   ";
  19.             } else if(i == rows-1){
  20.                 cout << "*" << "   ";
  21.             } else {
  22.                 cout << "    ";
  23.             }
  24.         }
  25.         cout << endl;
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement