class Solution { public: /** * * @param x int整型 * @return int整型 */

int reverse(int x) {
    // write code here
    bool flag = 1;
    if(x < 0) flag = 0;
    x = abs(x);
    string res = to_string(x);
    
    std::reverse(res.begin(), res.end());
    
    long long ans = 0;
    ans = std::atoll(res.c_str());
    
    if(ans > INT_MAX)
    {
        return 0;
    }
    if(!flag)
    {
        ans = -ans;
    }
    return ans;
    
}

};