[leetcode-504-Base 7]
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].
string convertToBase7(int num)
{
if (num == ) return "";
string ret = "";
int temp = num;
if (num < ) num = -num;
while (num)
{
ret.insert(ret.begin(), num % + '');
//ret = to_string(num % 7) + ret;//to_string用法
num /= ;
}
if (temp < )ret.insert(ret.begin(), '-');
return ret;
}
[leetcode-504-Base 7]的更多相关文章
- 45. leetcode 504. Base 7
504. Base 7 Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: ...
- [LeetCode] 504. Base 7 基数七
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...
- [LeetCode] 504. Base 7_Easy tag: Math
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...
- LeetCode 504. Base 7 (C++)
题目: Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "2 ...
- C#版 - Leetcode 504. 七进制数 - 题解
C#版 - Leetcode 504. 七进制数 - 题解 Leetcode 504. Base 7 在线提交: https://leetcode.com/problems/base-7/ 题目描述 ...
- 【leetcode】504. Base 7
problem 504. Base 7 solution: class Solution { public: string convertToBase7(int num) { ) "; st ...
- 【LeetCode】504. Base 7 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 内建库 BigInteger类 逐位计算 倍数相加 ...
- [LeetCode&Python] Problem 504. Base 7
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...
- 504. Base 7
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...
- 504 Base 7 七进制数
给定一个整数,将其转化为7进制,并以字符串形式输出.示例 1:输入: 100输出: "202" 示例 2:输入: -7输出: "-10"注意: 输入范围是 [- ...
随机推荐
- java中一个重要思想:面向对象
面向对象: 1, 面向过程的思想(合适的方法出现在合适的类里面) 准备去一个地方: 先买车, 挂牌, 开导航, 踩油门, 过黄河, 穿越珠穆朗玛峰... 2, 面向对象的思想 我开着车去, 车怎么去随 ...
- Js之on与addEventListener的使用与两者的不同
Js之on和addEventListener的使用与不同 一.首先介绍两者的用法: 1.on的用法:以onclick为例 第一种: obj.onclick = function(){ //do som ...
- CentOS 6.x 本地yum源配置与使用
系统默认已经安装了可使用yum的软件包,所以可以直接配置: # mount /dev/cdrom /mnt 挂载镜像,可以写到配置文件 ...
- R语言 模糊c均值(FCM)算法程序(转)
FCM <- function(x, K, mybeta = 2, nstart = 1, iter_max = 100, eps = 1e-06) { ## FCM ## INPUTS ## ...
- C语言之函数
函数:为了完成某一项功能而编写的代码的集合. C语言中的函数可以分为内置和自定函数. 内置函数:C语言中已经定义过的函数,不需要 声明,可以直接调用. 常见的内置函数: 函数名 类库 说明 doubl ...
- [HDU1004] Let the balloon rise - 让气球升起来
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- redis学习(2)--- Redis概述
一.Redis介绍 高性能键值对数据库,支持的键值对数据类型: 字符串类型 列表类型 有序集合类型 散列类型 集合类型 官方测试读写速度: 测试50个并发程序,执行10万次请求 读的速度:每秒11万次 ...
- 1.JAVA WEB 笔记中文乱码
JAVA WEB 乱码问题解析 乱码原因 在Java Web开发过程中,经常遇到乱码的问题,造成乱码的原因,概括起来就是对字符编码和解码的方式不匹配. 既然乱码的原因是字符编码与解码的方式不匹配,那么 ...
- java书系列之——前言
第1章Java的起源 对于计算机语言的发展史,业界一般认为:B语言导致了C语言的诞生,C语言演变出了C++语言,而C++语言将让位于Java语言.要想更好地了解Java语言,就必须了解它产生的原因.推 ...
- javamail 邮件格式再优化(由详情——>改为统计)
前言:之前扩展的ant-jmeter支持邮件附件形式上传以及邮件内容的html文件格式. 如图: 由于邮件的内容格式是详情信息,也就是说直观的显示的是case,但由于case的增加,邮件内容越来越大! ...