【LeetCode】 504. Base 7
2017-08-29 14:13
423 查看
Given an integer, return its base 7 string representation.
Example 1:
Input: 100
Output: “202”
Example 2:
Input: -7
Output: “-10”
题目就是转换为7进制的数字。
Example 1:
Input: 100
Output: “202”
Example 2:
Input: -7
Output: “-10”
题目就是转换为7进制的数字。
class Solution { public: string convertToBase7(int num) { string s; int fla=0; if(num<0){ num=-num; fla=1; } if(num==0)s="0"; while(num){ s=to_string(num%7)+s; num/=7; } if(fla)s='-'+s; return s; } };
相关文章推荐
- 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 (Java)
- leetcode:504. Base 7
- leetcode 504. Base 7
- leetcode 504. Base 7(easy)
- LeetCode 504. Base 7
- LeetCode504. 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【E】【94】