MeehoweCK

Untitled

Nov 2nd, 2020
2,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cout << "Podaj wysokosc choinki: ";
  9.     cin >> n;
  10.     int k = 2 * n - 1;
  11.  
  12.     for(int i = 0; i < n; ++i)      // zmienna i określa nr wiersza
  13.     {
  14.         for(int j = 0; j < k; ++j)  // zmienna j określa nr kolumny
  15.         {
  16.             if(((i + j) < (k - 1)/2) || (j > (k - 1)/2 + i))
  17.                 cout << ' ';
  18.             else
  19.                 cout << '*';
  20.         }
  21.         cout << endl;
  22.     }
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment