class Solution {
public int reverse(int x) {
int reslut = 0;
while(x != 0){
int tail = x % 10;
int newResult = reslut * 10 + tail;
if((newResult - tail) / 10 != reslut){
return 0;
}
reslut = newResult;
x = x / 10;
}
return reslut;
}
}
7. 整数反转
最新推荐文章于 2022-10-16 20:59:24 发布