码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode 7. Reverse Integer

时间:2016-11-01 00:47:39      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:style   public   blog   ever   color   min   etc   tco   max   

        public int Reverse(int input)
        {
            long reversedNum = 0;
            while (input != 0)
            {
                reversedNum = reversedNum * 10 + input % 10;
                input = input / 10;
            }
            if (reversedNum > int.MaxValue || reversedNum < int.MinValue)
            {
                reversedNum = 0;
            }
            return Convert.ToInt32(reversedNum);
        }

 

LeetCode 7. Reverse Integer

标签:style   public   blog   ever   color   min   etc   tco   max   

原文地址:http://www.cnblogs.com/pengdotnet/p/Reverse-Integer.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!