判断是否是回文数
/*回文数判断*/ #include <iostream> #include <string> using namespace std; int main() { string str; cin >> str; int backward = 0; int farward = str.size() - 1; for ( ; backward <= farward; backward++, farward--) { if (str[backward] != str[farward]) { break; } } if (backward > farward) { cout << "是回文数"; } else { cout << "不是回文数"; } }