首页 > 其他 > 详细

leetcode-----7. 整数反转

时间:2020-06-02 17:16:21      阅读:32      评论:0      收藏:0      [点我收藏+]
  • 链接:https://leetcode-cn.com/problems/reverse-integer/

代码

class Solution {
    public int reverse(int x) {
        int ans = 0;
        while (x != 0) {
            int tmp = x % 10 + ans * 10;
            if ((tmp - x % 10) / 10 != ans) return 0;
            ans = tmp;
            x /= 10;
        }
        return ans; 
    }
}

leetcode-----7. 整数反转

原文:https://www.cnblogs.com/clown9804/p/13031520.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!