Run ID:47974
提交时间:2023-05-14 15:59:53
//#include <bits/stdc++.h> #include <iostream> #include <string> using namespace std; string str, s; bool isHuiWen(string s) { for(int i = 0; i < s.size()/2; i++){ if (s[i] != s[s.size() - i - 1]) { return false; } } return true; } int main() { //freopen("a.in", "r", stdin); //freopen("b.out", "w", stdout); cin >> str; int max = 1; for (int i = 0; i < str.size() - 1; i++) { for (int j = str.size()-1; j >= i + max; j--) { s = str.substr(i, j - i + 1); if (isHuiWen(s)) { if (s.size() > max) { max = s.size(); break; } } } } cout << max << endl; return 0; }