9. Palindrome Number

来源:互联网 发布:数据中心网络拓扑图 编辑:程序博客网 时间:2024/05/18 17:24

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

没啥好说,判断一个数字是否为回文数字。

class Solution {public:    bool isPalindrome(int x) {        int newx = 0;        int xx = x;        while(xx > 0)        {            newx = newx * 10;            newx = newx + xx % 10;            xx = xx / 10;        }        if(newx == x)            return 1;        else            return 0;    }};
0 0
原创粉丝点击