完整代码如下:
#include#include using namespace std; bool isPalindrome(int num){ if (num < 0) return false; else{ string s = to_string(num); int left = 0, right = s.length() - 1; while (left < right){ if (s[left] != s[right]) return false; else left++, right--; } return true; } } int main(){ int num; cout << "please enter a number:"; cin >> num ; cout << "the result is:" << isPalindrome(num) << endl; system("pause"); }



