Advertisement
krasio12356

Skyscraper

Apr 17th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.                                         // Skyscraper
  5. string r(string s, int n)
  6. {
  7.     string answer;
  8.     for (int i = 0; i < n; i++)
  9.     {
  10.         answer = answer + s;
  11.     }
  12.     return answer;
  13. }
  14.  
  15. int main()
  16. {
  17.     int n;
  18.     cin >> n;
  19.     for (int i = 0; i < n - 3; i++)
  20.     {
  21.         cout << r(" ", n) << "|" << endl;
  22.     }
  23.     cout << r(" ", n - 1) << "_|_" << endl;
  24.     for (int i = 0; i < n - 3; i++)
  25.     {
  26.         cout << r(" ", n - 1) << "|-|" << endl;
  27.     }
  28.     cout << r(" ", n - 2) << "_|-|_" << endl;
  29.     for (int i = 0; i < n - 3; i++)
  30.     {
  31.         cout << r(" ", n - 2) << "|***|" << endl;
  32.     }
  33.     cout << " " << r("_", n - 3) << "|***|" << r("_", n - 3) << endl;
  34.     for (int i = 0; i < n * 4 - 1; i++)
  35.     {
  36.         cout << " " << r("|", n - 2) << "---" << r("|", n - 2) << endl;
  37.     }
  38.     cout << "_" << r("|", n - 2) << "---" << r("|", n - 2) << "_" << endl;
  39.     for (int i = 0; i < n - 2; i++)
  40.     {
  41.         cout << r("|", 2 * n + 1) << endl;
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement