SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include "bits/stdc++.h"
  3. using namespace std;
  4.  
  5. bool IsPalindrom(const std::string& str)
  6. {
  7.   for(size_t i = 0; i < str.size() / 2; i++)
  8.     if(str[i]!=str[str.size()-1-i])
  9.       return false;
  10.   return true;
  11. }
  12.  
  13. int main()
  14. {
  15.     string s;
  16.     cin >> s;
  17.     for (int i = 0; i < s.size(); i ++){
  18.         string s1;
  19.         s1 = s.substr(0,i)+s.substr(i+1);
  20.         if (IsPalindrom(s1)==1){
  21.             cout << i+1<< endl;
  22.             return 0;
  23.         }
  24.     }
  25.     cout << 0  << endl;
  26.     return 0;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top