NIKOLAY_TETUS

Lab2_def

Apr 14th, 2022
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string str;
  9.     cout << "string>";
  10.     cin >> str;
  11.    
  12.     size_t n = 0;
  13.     cout << "n>";
  14.     cin >> n;
  15.    
  16.     if (n > str.size() / 2)
  17.     {
  18.         cout << "Error: N is too big, or string is too small" << endl;
  19.         return 0;
  20.     }
  21.    
  22.     //cout << str.substr(0, n) << str.substr(n, str.size() - n - 2) << str.substr(str.size() - n) << endl;
  23.     cout << str.substr(str.size() - n) << str.substr(n, str.size() - n - 2) << str.substr(0, n) << endl;
  24.    
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment