/* a good way to predict overflow
* each time *10 must predict int overflow
* not only the last time to predict which will be wrong.
*/
class Solution {
public:
int reverse(int x) {
if(x==)return x;
int tag=;
long int re=;
if(x<)
{
tag=;
x=-x;
}
while(x)
{
int tmp=re*+x%;
if((tmp-x%)/!=re)return ;
re=tmp;
x=x/;
}
if(tag)re=-re;
return re;
}
};
相关文章
- Evaluate Reverse Polish Notation (STRING-TYPE CONVERTION)
- 11. Evaluate Reverse Polish Notation
- Python: How to iterate list in reverse order
- [LeetCode]Evaluate Reverse Polish Notation(逆波兰式的计算)
- java面试题(杨晓峰)---第七讲谈谈int和integer有什么区别?
- [LintCode] Reverse Integer 翻转整数
- 如何在Eclipse RCP应用程序(SWT)中绑定组合的selectionIndex和Integer?
- hdu1047 Integer Inquiry 多次大数相加
- Java基础之 Integer 类源码分析
- 7. 反转整数(Reverse Integer) C++