class Solution {
public int reverse(int x) {
int res = 0;
while(x!=0){
res = res*10+x%10;
// 判断整数溢出
if(res%10!=x%10){
return 0;
}
x=x/10;
}
return res;
}
}