解题思路: 运用反向迭代器
注意事项: 运用重载了的string的'=='运算符
参考代码:
#include<iostream> #include<string> using namespace std; int main() { string str, str2; cin >> str; string::reverse_iterator ptr = str.rbegin(); while (ptr != str.rend()) str2 += *(ptr++); if (str == str2)cout << "YES"; else cout << "NO"; return 0; }
0.0分
2 人评分