leetcode:Palindrome Number [9]

来源:互联网 发布:淘宝绫致时装官方店 编辑:程序博客网 时间:2024/06/03 20:53

Determine whether an integer is a palindrome. Do this without extra space.


class Solution {public:bool isPalindrome(int x) {int d = x;int a = 0;if (x >= 0)while (x != 0) {a = x % 10 + a * 10;x /= 10;}elsewhile (x != 0) {a =- x % 10 + a * 10;x /= 10;}if (a == d) return true;else return false;}};




0 0
原创粉丝点击