504. Base 7
来源:互联网 发布:单片机 http请求 编辑:程序博客网 时间:2024/05/22 04:24
题目来源【Leetcode】
Given an integer, return its base 7 string representation.
Example 1:
Input: 100
Output: “202”Example 2:
Input: -7
Output: “-10”
Note: The input will be in range of [-1e7, 1e7].
把十进制数变为7进制数,比较简单,直接放代码
class Solution {public: string convertToBase7(int num) { string re; int temp = abs(num); if(num == 0) return "0"; while(temp != 0){ int t = temp%7; re += to_string(t); temp = temp/7; } reverse(re.begin(),re.end()); if(num < 0) re = "-"+re; return re; }};
阅读全文
0 0
- Leetcode-504. Base 7
- 【Leetcode】504. Base 7
- LeetCode 504. Base 7
- 504. Base 7
- [leetcode]504. Base 7
- 504. Base 7
- 504. Base 7
- 504. Base 7
- 504. Base 7
- LeetCode-504. Base 7
- 504. Base 7
- 504. Base 7
- 504. Base 7
- leetcode 504. Base 7
- 504. Base 7
- LeetCode:504. Base 7
- [LeetCode]504. Base 7
- leetcode 504. Base 7
- hdu 2852 KiKi's K-Number(树状数组)
- 理解 typename 的两个含义
- 微信自动关闭内置浏览器页面,返回公众号窗口
- 扩展欧几里得
- 第四章:Django模型——admin后台管理
- 504. Base 7
- 206. Reverse Linked List
- 中企动力与湖南源峰现代农业公司同行 共享全网营销平台
- 北京网信办整治自媒体八大乱象 腾讯网易凤凰在列
- Struts2学习总结(十):paramsPrepareParams拦截器栈
- linux 网卡对应网口查看方式
- echarts 实现柱状图左右横向显示
- 关于QT的那些事(二)
- N-Queens II