Leetcode Reverse Integer

class Solution {
public:
    int reverse(int x) 
    {
        int y=abs(x);
        int z=0;
        while(y>0)
        {
           z=z*10+y%10;
           y=y/10;
        }
        if(x>0)return z;
        if(x<0)return -z;       
    }
};

 

posted @ 2013-06-13 00:09  代码改变未来  阅读(121)  评论(0编辑  收藏  举报