class Solution {

public:

int reverse(int x)

{

int sign=x>>31;

int ret=0;

int lastBit=x%10;

int bCnt=0;

while(x)

{

ret = ret*10+x%10;

x = x/10;

bCnt++;

if((bCnt>=10)&&(lastBit>=3)) return 0;

}

if(bCnt>=10)

if((ret>>31)!=sign)return 0;

return ret;

}

};