Advertisement
HyperSensualNarwhal

Asterisk rhombus formation

Nov 25th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. // *asterisk frmtn improved
  2.  
  3. #include <iostream>
  4.  
  5. using std::cout;
  6. using std::cin;
  7. using std::endl;
  8.  
  9. void main()
  10. {
  11.     setlocale(LC_ALL, "Russian");
  12.  
  13.     int a;
  14.     char ch = '*';
  15.  
  16.     cout << "Введите размер фигуры: "; cin >> a;
  17.     cout << endl;
  18.  
  19.  
  20.     for (int i = 0; i <= a-1; i++)
  21.     {
  22.         for (int j = a-1; j >= i; j--)
  23.         {
  24.         cout << " ";
  25.         }
  26.  
  27.         for (int j = 0; j <= i; j++)
  28.         {  
  29.             cout << ch;
  30.         }
  31.  
  32.         cout << " ";
  33.  
  34.         for (int j = 0; j <= i; j++)
  35.         {
  36.             cout << ch;
  37.         }
  38.  
  39.         cout << endl;
  40.     }
  41.  
  42.     cout << endl;
  43.    
  44.     for (int i = a-1; i >= 0; i--)
  45.     {
  46.         for (int j = a-1; j >= i; j--)
  47.         {
  48.             cout << " ";
  49.         }
  50.  
  51.         for (int j = 0; j <= i; j++)
  52.         {
  53.             cout << ch;
  54.         }
  55.  
  56.         cout << " ";
  57.  
  58.         for (int j = 0; j <= i; j++)
  59.         {
  60.             cout << ch;
  61.         }
  62.  
  63.         cout << endl;
  64.  
  65.     }
  66.  
  67.     cout << endl;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement