#include <iostream>
#include<vector>
using namespace std;
bool isPalindrome(int x) {
vector<int>v;
int leng=0;
int res = 0;
while (x)
{
v.push_back(x % 10);
x = x / 10;
leng++;
}
for (int i = 0; i < leng; i++)
{
if (v[i] == v[leng - i-1])
{
res++;
}
else
{
return false;
}
}
if (res == leng)
{
return true;
}
}
int main()
{
int x = 1221;
if (isPalindrome(x))
{
cout << x << endl;
}
return 0;
}
回文数判断
最新推荐文章于 2024-11-06 11:05:01 发布