这里的话,我自己没做出来,其实这里的话,需要使用无符号的整数
class Solution {
public:
int reverse(int x) {
unsigned int res=0;
while(x){
int tmp=res*10+x%10;
if(tmp/10==res) res=tmp;
else return 0;
x=x/10;
}
return res;
}
};
京公网安备 11010502036488号