Niloy007

Sobuj Problem's Solution

Nov 27th, 2021 (edited)
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     int k = n / 2;
  9.     int a = k, b = k;
  10.  
  11.     for (int i = 0; i < k; i++) {
  12.         for (int j = 0; j < n; j++) {
  13.             if (j == k) {
  14.                 cout << '$';
  15.             } else if (j == a) {
  16.                 cout << '$';
  17.             }
  18.             else if (j == b) {
  19.                 cout << '$';
  20.             } else {
  21.                 cout << '_';
  22.             }
  23.         }
  24.         cout << endl;
  25.         a--;
  26.         b++;
  27.     }
  28.     for (int i = 0; i < n; i++) {
  29.         cout << '$';
  30.     }
  31.     cout << endl;
  32.     a++;
  33.     b--;
  34.     for (int i = k + 1; i < n; i++) {
  35.         for (int j = 0; j < n; j++) {
  36.             if (j == k) {
  37.                 cout << '$';
  38.             } else if (j == a) {
  39.                 cout << '$';
  40.             }
  41.             else if (j == b) {
  42.                 cout << '$';
  43.             } else {
  44.                 cout << '_';
  45.             }
  46.         }
  47.         cout << endl;
  48.         a++;
  49.         b--;
  50.     }
  51. }
Add Comment
Please, Sign In to add comment