The_Law

Untitled

Apr 1st, 2021
810
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. #include <cmath>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. string raw;
  9. vector<char> rev;
  10.  
  11.  
  12. int main()
  13. {
  14.   getline(cin, raw);
  15.   for (int i = raw.size() - 1; i >= 0; --i) {
  16.     rev.push_back(raw[i]);
  17.   }
  18.  
  19.   int j = raw.size() - 1;
  20.   for (int i = 0; i <= j; ++i) {
  21.     if (raw[i] == raw[j]) {
  22.       bool is_ok = true;
  23.       for (int q = i, l = 0; q <= i + (j - i + 1) / 2; ++q, ++l) {
  24.         if (raw[q] != rev[l])
  25.           is_ok = false;
  26.       }
  27.       if (is_ok) {
  28.         cout << i;
  29.         break;
  30.       }
  31.     }
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment