[leetcode]504. Base 7
2017-07-15 21:10
381 查看
题目链接:https://leetcode.com/problems/base-7/#/description
Given an integer, return its base 7 string representation.
Example 1:
Example 2:
Given an integer, return its base 7 string representation.
Example 1:
Input: 100 Output: "202"
Example 2:
Input: -7 Output: "-10"
class Solution { public: string convertToBase7(int num) { if(num==0) return "0"; int number=abs(num); string res=""; while(number) { int n=number%7; res=to_string(n)+res; number/=7; } if(num<0) res="-"+res; return res; } };
相关文章推荐
- [leetcode]504. Base 7
- 【LeetCode】504. Base 7【E】【94】
- LeetCode 504. Base 7
- [Leetcode] 504. Base 7 解题报告
- [leetcode: Python]504. Base 7
- LeetCode_504. Base 7
- leetcode 504. Base 7 转换七进制
- leetcode 504. Base 7
- [leetcode]: 504. Base 7
- LeetCode:504. Base 7
- Leetcode-504. Base 7
- LeetCode 504. Base 7
- LeetCode-504. Base 7
- (Leetcode)504. Base 7
- leetcode 504. Base 7 python
- leetcode 504. Base 7
- 【Leetcode】504. Base 7
- 【LeetCode】 504. Base 7
- leetcode 504. Base 7
- LeetCode-504. Base 7 (Java)