Reverse digits of an integer.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Reverse digits of an integer.相关的知识,希望对你有一定的参考价值。
?????????
class Solution { public: int reverse(int x) { ?????? long ans=0;//long ???????????????????????? int min=1<<31,max=-min-1;//???????????????<<???????????????while(x!=0){ ans=ans*10+x%10; x=x/10; } if(ans>max||ans<min) return 0; return ans; } };
?????????
?????????????????????????????????
?????????????????????????????????????????????
??????????????????????????????????????????
??????
32????????????
unsigned int 0???4294967295
int -2147483648???2147483647 ???-2^31~???2^31-1??????//????????????????????????1??????
unsigned long 0???4294967295
long -2147483648???2147483647
long long???????????????9223372036854775807
long long???????????????-9223372036854775808
unsigned long long???????????????1844674407370955161
__int64???????????????9223372036854775807
__int64???????????????-9223372036854775808
unsigned __int64???????????????18446744073709551615
以上是关于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