判断一个数是不是回文数?
问题描述:
判断一个数是不是回文数?
答
bool isPalindrome(int num){int pal = 0;int origin = num;while(num){pal *= 10;pal += num % 10;num /= 10;}return pal == origin;}
判断一个数是不是回文数?
bool isPalindrome(int num){int pal = 0;int origin = num;while(num){pal *= 10;pal += num % 10;num /= 10;}return pal == origin;}