Reverse digits of an integer.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Reverse digits of an integer.相关的知识,希望对你有一定的参考价值。
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); } };
本文出自 “算法设计” 博客,请务必保留此出处http://shineprince.blog.51cto.com/10293320/1913900
以上是关于Reverse digits of an integer.的主要内容,如果未能解决你的问题,请参考以下文章
1281. Subtract the Product and Sum of Digits of an Integer
LeetCode --- 1281. Subtract the Product and Sum of Digits of an Integer 解题报告
Leet code problem 7: reverse integer digit
leetcode-Evaluate the value of an arithmetic expression in Reverse Polish Notation