Advertisement
DidiMilikina

05.Триъгълник

Oct 30th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. //URL FOR THE TASK: https://judge.softuni.bg/Contests/Practice/Index/642#4
  2.  
  3.  
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10.     int n;
  11.     cin >> n;
  12.  
  13.     int width = 4 * n + 1;
  14.     int height = 2 * n + 1;
  15.  
  16.     cout << string(width, '#') << endl;
  17.  
  18.     int side_dots = 1;
  19.     int inner_spaces = 1;
  20.  
  21.     for (int i = 0; i < n; i++)
  22.     {
  23.         int number_of_tags = (width - side_dots * 2 - inner_spaces) / 2;
  24.         cout << string(side_dots, '.');
  25.         cout << string(number_of_tags, '#');
  26.  
  27.         if (i == n / 2)
  28.         {
  29.             cout << string((inner_spaces - 3) / 2, ' ');
  30.             cout << "(@)";
  31.             cout << string((inner_spaces - 3) / 2, ' ');
  32.         }
  33.         else
  34.         {
  35.             cout << string(inner_spaces, ' ');
  36.         }
  37.  
  38.         cout << string(number_of_tags, '#');
  39.         cout << string(side_dots, '.') << endl;
  40.  
  41.         inner_spaces += 2;
  42.         side_dots++;
  43.     }
  44.     for (int i = 0; i < n; i++)
  45.     {
  46.         cout << string(side_dots, '.');
  47.         cout << string(width - side_dots * 2, '#');
  48.         cout << string(side_dots, '.') << endl;
  49.         side_dots++;
  50.     }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement