See the article on https://dyingdown.github.io/2019/12/20/HDU-2029%20Palindromes-easy-version/
Palindromes_easy version
A “palindrome string” is a string that is the same as both the forward and reverse reading. For example, “level” or “noon” is a palindrome string. Please write a program to determine whether the read string is “palindrome”.
Input
The input contains multiple test instances. The first line of input data is a positive integer n, which represents the number of test instances, followed by n strings.
Output
If a string is a palindrome, it outputs “yes”, otherwise it outputs “no”.
Analysis
Using C++ 11 features. reverse.
Code
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t --) {
string a, b;
cin >> a;
b = a;
reverse(b.begin(), b.end());
if(a == b) cout << "yes" << endl;
else cout << "no" << endl;
}
return 0;
}