intsas

Untitled

Mar 4th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. int main() {
  7.     std::string string;
  8.     while (std::cin >> string) {
  9.         for (auto end = string.end(); end != string.begin(); --end) {
  10.             auto sub_string = string.substr(0, end - string.begin());
  11.             auto rev_sub_string(sub_string);
  12.             std::reverse(rev_sub_string.begin(), rev_sub_string.end());
  13.  
  14.             if (sub_string == rev_sub_string) {
  15.                 std::cout << sub_string << std::endl;
  16.                 break;
  17.             }
  18.         }
  19.     }
  20.     return 0;
  21. }
Add Comment
Please, Sign In to add comment