Advertisement
legendmt25

elka - code finki lab

Dec 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void elka(int n);
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.     elka(n);
  12.     return 0;
  13. }
  14. void elka(int n)
  15. {
  16.     for (int i = 0, c = 1; i < n / 2 + 1; i++, c += 2)
  17.     {
  18.         for (int j = 0; j < n / 2 - i; j++)
  19.         {
  20.             cout << " ";
  21.         }
  22.         for (int j = 0; j < c; j++)
  23.         {
  24.             cout << "*";
  25.         }
  26.         for (int j = 0; j < n / 2 - i; j++)
  27.         {
  28.             cout << " ";
  29.         }
  30.         cout << "\n";
  31.     }
  32.     return;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement