Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <iterator>
- int main() {
- std::string string;
- while (std::cin >> string) {
- for (auto end = string.end(); end != string.begin(); --end) {
- auto sub_string = string.substr(0, end - string.begin());
- auto rev_sub_string(sub_string);
- std::reverse(rev_sub_string.begin(), rev_sub_string.end());
- if (sub_string == rev_sub_string) {
- std::cout << sub_string << std::endl;
- break;
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment