LeetCode_Reverse Integer

Reverse digits of an integer.

Example1: x = , return
Example2: x = -, return -
class Solution {
public:
int reverse(int x) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(x == ) return x;
int flag = ; if(x < )
{
x*= -;
flag = -;
}
vector<int> result;
while(x)
{
int temp = x %;
result.push_back(temp);
x/=;
}
int num = ;
for(int i = ; i< result.size(); i++)
{
num +=result[i];
num*=;
} return flag*num/ ;
}
};
上一篇:fluentd安装和配置,收集docker日志


下一篇:使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享