Advertisement
namemkazaza

Task 4

Oct 22nd, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. #include<cmath>
  5. #include<algorithm>
  6. using namespace std;
  7.  
  8. bool check_polindrom(string word){
  9.     int len = word.length();
  10.     for (int i = 0; i < len / 2; i++)
  11.     if (word[i] != word[len - i - 1])
  12.         return false;
  13.     return true;
  14. }
  15.  
  16. int main() {
  17.     string a;
  18.     getline(cin, a);
  19.     for (int i = 0; i < a.size(); i++) {
  20.         string b = a;
  21.         b.erase(i, 1);
  22.         if (check_polindrom(b)) {
  23.             cout << i + 1 << "\n";
  24.             system("pause");
  25.             return 0;
  26.         }
  27.     }
  28.     cout << "0" << "\n";
  29.     system("PAUSE");
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement