1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
class Solution { public: int reverse(int x) { long long intmax=(1<<31)-1,intmin=(1<<31)*(-1); long long ant=x,res=0; while(ant!=0){ res*=10; res+=ant%10; ant/=10; } if(res<intmin||res>intmax){ return 0; } return res; } };
|