/*** @Author :田宇寒.* @Date :Created in 10:20 2021年6月3日* @Description:整数反转 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。 如果反转后整数超过 32 位的有符号整数的范围,就返回 0* 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/reverse-integer* @Modified By:* @Version: $*/public class code7 {class Solution {public int reverse(int x) {int result = 0;int digit = 0;while (x != 0) {if (result < Integer.MIN_VALUE / 10 || result > Integer.MAX_VALUE / 10) {return 0;}digit = x % 10;result = result * 10 + digit;x /= 10;}return result;}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。