Palindrome number

来源:互联网 发布:h3c 添加免认证mac 编辑:程序博客网 时间:2024/06/09 15:20
class Solution {
public:
    bool isPalindrome(int x) 
{
   int h = x;
   if(x < 0)
   {
       return false;
   }
unsigned long int t = 0;
    while(x !=  0)
        {
        t=t*10 + x%10;
        x=x-(x%10);
        x=x/10;
}
if(t>2147483647)
   return false;
else 
{
   if(h == t)
   {
       return true;
   }
   else
   {
       return false;
   }
}
    }

};

//(负数没有回文数)

0 0
原创粉丝点击