对整数进行反转 如果反转之后的整数超过了范围 就返回0
public int reverse(int x){
int res=0;
while(x!=0){
int t=x%10; //对10取余数 得到末位的数字
int newRes=res*10+t;
//判断是否溢出
if((newRes-t)/10!=res){ //如果溢出就直接返回0
return 0;
}
res=newRes;
x=x/10;
}
return res;
}