LeetCode Reverse Integer
2014-06-01 20:48
288 查看
题目链接:https://oj.leetcode.com/problems/reverse-integer/
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
不解释
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
不解释
class Solution { public: int reverse(int x) { bool flag=false; if(x<0) flag=true; x=abs(x); int ans=0; while(x) { ans=ans*10+x%10; x/=10; } if(flag) ans=-ans; return ans; } };
相关文章推荐
- leetcode Reverse Integer & Reverse a string----重点
- leetcode[7]:Reverse Integer
- LeetCode 7 :Reverse Integer ---- 反转int整数
- Reverse Integer LeetCode
- Leetcode Problem.7—Reverse Integer
- LeetCode Reverse Integer
- LeetCode-Algorithms #007 Reverse Integer, Database #182 Duplicate Emails
- Reverse Integer -leetcode
- leetcode---Reverse Integer
- Reverse Integer - LeetCode
- 【Leetcode】之Reverse Integer
- LeetCode Reverse Integer
- LeetCode Palindrome Number && Reverse Integer 解法集合
- Reverse Integer - LeetCode
- leetcode-Reverse Integer-7
- Reverse Integer LeetCode Java
- [置顶] [LeetCode] Reverse Integer 整数反转
- LeetCode 7 Reverse Integer ( C++ )
- [LeetCode] Reverse Integer、Palindrome Number
- LeetCode练习-翻转数字(Reverse Integer)