您的位置:首页 > 其它

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

2015-09-01 18:06 106 查看
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;
}
};


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: