Reversedigitsofaninteger.
class Solution { public: int reverse(int x) { int num = 0,X=x; int count = 0; double sum = 0; while (X != 0) { X = X/ 10; count++; } for (int i = 0; i < count; i++) { num = x % 10; sum = sum * 10 + num; if (sum>INT_MAX || sum < INT_MIN) { return 0; break; } x = x / 10; } return int (sum); } };
标题名称:Reversedigitsofaninteger.
文章路径:http://cqwzjz.cn/article/pohges.html