//
// Created by on 8/31/2018.
//
/*
*
* */
#include <iostream>
#include <vector>
#include <cstring>
#include <deque>
#include <map>
using namespace std;
class Solution{
public:
int reverse(int x) {
long rev= 0;
while( x != 0){
rev= rev*10 + x % 10;//从后往前反转x
x= x/10;//去掉当前最后一位数
if( rev > INT32_MAX || rev < INT32_MIN)
return 0;
}
return (int) rev;
}
};
int main(){
int n,m;
cin>>n;
Solution s;
m = s.reverse(n);
cout<<m<<endl;
return 0;
}
【LeetCode】 - 反转字符串
猜你喜欢
转载自blog.csdn.net/weixin_32820767/article/details/82587422
今日推荐
周排行