Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- string repeat(char c, int n) {
- string result;
- for (int i = 0; i < n; i++) {
- result += c;
- }
- return result;
- }
- int main() {
- int n;
- cin >> n;
- int x = n > 4 ? n * 2 - (n / 2 + 2) * 2 : 0;
- printf("/%s\\%s/%s\\\n", repeat('^', n / 2).c_str(), repeat('_', x).c_str(), repeat('^', n / 2).c_str());
- for (int i = 0; i < n - 3; i++) {
- printf("|%s|\n", repeat(' ', n * 2 - 2).c_str());
- }
- 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());
- printf("\\%s/%s\\%s/\n", repeat('_', n / 2).c_str(), repeat(' ', x).c_str(), repeat('_', n / 2).c_str());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement