c++,简洁,没有使用long long
反转数字
http://www.nowcoder.com/questionTerminal/1a3de8b83d12437aa05694b90e02f47a
class Solution {
public:
/**
*
* @param x int整型
* @return int整型
*/
int reverse(int x) {
// write code here
int res = 0;
while (x != 0) {
int t = x % 10;
x /= 10;
if (res > INT_MAX / 10 ) return 0;
if (res < INT_MIN / 10 ) return 0;
res = res * 10 + t;
}
return res;
}
};