Normal Version
#include <iostream>
#include <string>
using namespace std;
inline bool is_palindrome(const string str) {
int length = str.length();
for (int i = 0; i < length / 2; ++i)
if (str[i] != str[length - i - 1])
return false;
return true;
};
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
string str; cin >> str;
if (is_palindrome(str)) cout << "YES";
else cout << "NO"; cout.put('\n');
return 0;
};
Simple Version
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
string str1, str2;
cin >> str1; str2 = str1;
reverse(str1.begin(), str1.end());
if (str1 == str2) cout << "YES";
else cout << "NO"; cout.put('\n');
return 0;
};