题解 | #回文字符串#
回文字符串
https://www.nowcoder.com/practice/df00c27320b24278b9c25f6bb1e2f3b8
#include <bits/stdc++.h>
using namespace std ;
int main()
{
string s ;
while(cin >> s)
{
int len = s.length() ;
int mid = len / 2 ;
int start = 0 ;
int end = 0 ;
string s1,s2 ;
if(len % 2 == 1)
{
s1 = s.substr(0 , (len -1) / 2) ;
s2 = s.substr(mid + 1 , (len - 1) / 2) ;
}
else
{
s1 = s.substr(0 , len / 2) ;
s2 = s.substr(mid , len / 2) ;
}
reverse(s2.begin(),s2.end());
// cout << s1 << " " << s2 << endl ;
if(s1 == s2)
cout << "Yes!" << endl ;
else cout << "No!" << endl ;
}
return 0 ;
}

