思路;一个比较不废脑子的办法就是直接反转字符串,当然双指针两端也可以。
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
while (cin >> n) {
string s;
while (n--) {
cin >> s;
string n_s = s;
reverse(n_s.begin(), n_s.end());
if (s == n_s)
cout << "yes" << endl;
else
cout << "no" << endl;
}
}
}