Advertisement
HyperSensualNarwhal

Inverted arrow by ' * ' in 3 for loops ;(

Dec 2nd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. /*
  2.     *
  3.    **
  4.   ***
  5.  ****
  6. *****
  7.  
  8. *****
  9.  ****
  10.   ***
  11.    **
  12.     *
  13. */
  14. #include <iostream>
  15.  
  16. using std::cout;
  17. using std::cin;
  18. using std::endl;
  19.  
  20. void main()
  21. {
  22.     setlocale(LC_ALL, "Russian");
  23.  
  24.     int a, b = 0;
  25.  
  26.     cout << "Введите размер: "; cin >> a;
  27.  
  28.     a *= 2;
  29.  
  30.     for (int i = 0; i < a; i++, ((i == (a / 2)) ? cout << endl << endl : cout << endl))
  31.     {
  32.         if (i < (a / 2)) b++; else if (i == (a / 2)) b = a / 2; else b--;
  33.         for (int j = (a / 2) + 1; j > b; j--, cout << " "); // выравнивание
  34.         for (int k = 0; k < b; k++, cout << '*');
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement