Reverse Integer

问题:翻转数字
分析:注意初始化

class Solution {
public:
    int reverse(int x) {
        int y=0;
        while(x)
        {
           y=(y*10)+x%10;
           x/=10;
        }
        return y;
    }
};

  

posted @ 2014-08-01 18:32  calmound  阅读(95)  评论(0编辑  收藏  举报