📂java
🔖int
2021-01-07 10:53阅读: 121评论: 0推荐: 0

java int

1.整数反转

复制代码
    /**
     * 整数反转
     * @param x
     * @return
     */
    public static int reverse(int x) {
        long res = 0;

        while (x != 0) {
            res = res * 10 + x % 10;
            x /= 10;
        }
        return (int) res == res ? (int) res : 0;
    }
复制代码

 这可真是绝活了,无意间在网上看到的。

本文作者:zydjjcpdszylddpll

本文链接:https://www.cnblogs.com/jyfs/p/14245223.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   zydjjcpdszylddpll  阅读(121)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起