Leetcode 7 Reverse Integer

来源:互联网 发布:跑跑卡丁车淘宝刷车队 编辑:程序博客网 时间:2024/05/16 15:08

Leetcode 7 Reverse Integer

#include <sstream>#include <string>using namespace std;class Solution {public:    int reverse(int x) {        int y = 0;        while(x != 0){            if (y > INT_MAX / 10 || y < INT_MIN /10)                return 0;            int temp= x % 10;            y =10*y + temp;            x = x / 10;        }        return y;    }};
原创粉丝点击