publicstaticintreverse(int x){long i =0;int k = x;while(k !=0){
i =10* i + k %10;
k = k /10;}if(i > Integer.MAX_VALUE || i < Integer.MIN_VALUE){return0;}return(int)i;}
实现代码public static int reverse(int x) { long i = 0; int k = x; while(k != 0) { i = 10 * i + k % 10; k = k / 10; } if(i > Integer.MAX_VALUE || i < Integer.MIN_VALUE) { return 0; } return (int)i; }