STANAANDREY

caius iac SB2 with std::string

Apr 8th, 2022 (edited)
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <conio.h>
  3. using namespace std;
  4.  
  5. string read() {
  6.     string s;
  7.     char ch;
  8.     do {
  9.         ch = getch();
  10.         if (!isdigit(ch)) {
  11.             break;
  12.         }
  13.         s += ch;
  14.     } while(true);
  15.     return s;
  16. }
  17.  
  18. int main() {
  19.     string s = read();
  20.     int n = s.size();
  21.     //top part
  22.     for (int i = 0; i < (n + 1) / 2; i++) {
  23.         cout << string(i, ' ') + s.substr(i, n - i * 2) << endl;
  24.     }
  25.     //bottom part
  26.     for (int i = (n + 1) / 2 - 1; i >= 0; i--) {
  27.         cout << string(i, ' ') + s.substr(i, n - i * 2) << endl;
  28.     }//*/
  29.     return 0;
  30. }
  31.  
Add Comment
Please, Sign In to add comment