#include "iostream" #include "algorithm" #include "cstdio" #include "cstring" using namespace std; int main() { string s; int n; cin >> n; while(n--) { cin >> s; int len; int flag = 0; len = s.length(); for(int i=0;i < len/2;i++) { if(s[i] != s[len-i-1]) flag++; } if(flag == 0 && len%2 == 1) cout << "YES"<<endl; else if(flag == 1) cout << "YES"<< endl; else cout << "NO"<<endl; } return 0; }
1.计算字符串的长度 s.length()