#include <iostream>
using namespace std;
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0) return false;
int m = x, n = 1;
while (m /= 10) n *= 10;
m = x;
while (m)
{
if (m / n != x % 10) return false;
x /= 10;
m %= n;
n /= 10;
}
return true;
}
};
int main()
{
int x;
Solution so;
while (cin >> x) cout << so.isPalindrome(x) << endl;
return 0;
}
9.判断一个数字是否为回文
最新推荐文章于 2020-03-08 17:27:51 发布