Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <vector>
- using namespace std;
- string raw;
- vector<char> rev;
- int main()
- {
- getline(cin, raw);
- for (int i = raw.size() - 1; i >= 0; --i) {
- rev.push_back(raw[i]);
- }
- int j = raw.size() - 1;
- for (int i = 0; i <= j; ++i) {
- if (raw[i] == raw[j]) {
- bool is_ok = true;
- for (int q = i, l = 0; q <= i + (j - i + 1) / 2; ++q, ++l) {
- if (raw[q] != rev[l])
- is_ok = false;
- }
- if (is_ok) {
- cout << i;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment