I don't how to do it. so I using long long save resualt, and at end I convert it to int and compare it,do you have any way else? thanks.

class Solution {

public:

int reverse(int x) {

long long int ret=0;

do

{

ret*=10;

ret+=x%10;

}

while(x/=10);

return ret==int(ret)?ret:0;

}

};