题解 | 回文字符串
#include<iostream> #include<string> using namespace std; int main(){ string str; while(cin>>str){ int mid = str.length()/2 + 1; bool flag = false; for(int i = 0;i<mid;i++){ if(str[i]!=str[str.length()-1-i]){ cout<<"No!"<<endl; flag = true; break; } } if(!flag){ cout<<"Yes!"<<endl; } } }