题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,
十位与千位相同。
#include <iostream>
using namespace std;
bool isPalindrome(unsigned int num)
{
if((num < 10000) || (num > 100000))
return false;
unsigned int bits = num % 10;
unsigned int ten = num % 100 / 10;
unsigned int thousand = num % 10000 / 1000;
unsigned int theThousand = num / 10000;
if( (bits == theThousand) && (ten == thousand) )
return true;
else
return false;
}
main()
{
isPalindrome(67576);
for( int i=10000; i<100000; i++ )
if( isPalindrome(i) )
cout<<i<<" ";
}