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.
本文URL:http://azwzsj.com/article/pohges.html