LeetCode 7 Reverse Integer int:2147483647-2147483648 难度:2

https://leetcode.com/problems/reverse-integer/

class Solution {
public:
int inf = ~0u >> 1;
int reverse(int x) {
if(x == 0)return 0;
long long tx = x;
long long ans = 0;
for(int i = 0;tx;i++){
ans = ans * 10 + tx % 10;
tx /= 10;
}
return int(ans) == ans?ans:0;
}
};

  

上一篇:Ubuntu sudo apt-get 安装下载更新软件包命令详解


下一篇:C#获取电脑型号、系统版本、内存大小、硬盘大小、CPU信息