整数逆序

时间:2014-10-27 22:55:25   收藏:0   阅读:165
 1 class Solution
 2 {
 3     public: 
 4         
 5         int reverse(int x){
 6         int result=0;
 7             while(x!=0)
 8             {
 9                 result=result*10+x%10;
10                 x/=10;
11             }
12             return result;
13         }
14 };

和判断整数是否是回文数字里面的方法一样。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!