题目
输入一个正整数,判断它是否为回文数,所谓回文数即正读和反读都是一样的数,如 12321、56465 都是回文数。
相关阅读
完整代码
#include<bits/stdc++.h>
using namespace std;
bool isPalindromeNumber(int n){
int temp = n;
int sum = 0;
while (temp != 0){
sum = sum*10 + temp%10;
temp /= 10;
}
if (sum == n)
return true;
else
return false;
}
int main(){
int n;
cin >> n;
if (isPalindromeNumber(n))
cout << n << " is palindrome number!" << endl;
else
cout << n << " is not palindrome number!" << endl;
}