Advertisement
Spocoman

Draw Fort

Oct 11th, 2023
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. string repeat(char c, int n) {
  6.     string result;
  7.     for (int i = 0; i < n; i++) {
  8.         result += c;
  9.     }
  10.     return result;
  11. }
  12.  
  13. int main() {
  14.     int n;
  15.     cin >> n;
  16.  
  17.     int x = n > 4 ? n * 2 - (n / 2 + 2) * 2 : 0;
  18.  
  19.     printf("/%s\\%s/%s\\\n", repeat('^', n / 2).c_str(), repeat('_', x).c_str(), repeat('^', n / 2).c_str());
  20.  
  21.     for (int i = 0; i < n - 3; i++) {
  22.         printf("|%s|\n", repeat(' ', n * 2 - 2).c_str());
  23.     }
  24.  
  25.     printf("|%s%s%s|\n", repeat(' ', (n * 2 - (x + 2)) / 2).c_str(), repeat('_', x).c_str(), repeat(' ', (n * 2 - (x + 2)) / 2).c_str());
  26.  
  27.     printf("\\%s/%s\\%s/\n", repeat('_', n / 2).c_str(), repeat(' ', x).c_str(), repeat('_', n / 2).c_str());
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement