Palindromes _easy version
#include <iostream> #include <cstring> #include <string> using namespace std; int main() { string s; int n, i, j, len; cin >> n; while(n --) { cin >> s; len = s.length(); bool flag = true; for(i = 0, j = len - 1; i < j; ++ i, -- j) { if(s[i] != s[j]) { flag = false; break; } } if(flag) cout << "yes" << endl; else cout << "no" << endl; } return 0; }