文章目录 tips INT_MAX=2147483647,10位数,20多亿 负数与正数处理方式一样 判断是否溢出: 1234 if(next / 10 != res) { res = 0 break } 12345678910111213141516 class {public: int reverse(int x) { int res = 0; while(x != 0) { int next = res * 10 + x % 10; x = x / 10; if(next / 10 != res) { res = 0; break; } res = next; } return res; }}; 赞微海报分享
近期评论