public class Solution {
public string ConvertToBase7(int num) {
var prefix = num >= ? "" : "-";
var list = new List<string>();
StringBuilder sb = new StringBuilder();
num = Math.Abs(num);
do
{
var n = num % ;
sb.Append(n.ToString());
num = num / ;
} while (num != ); var result = sb.ToString() + prefix;
var list2 = result.Reverse();
sb.Clear();
foreach (var c in list2)
{
sb.Append(c);
}
return sb.ToString();
}
}

https://leetcode.com/problems/base-7/#/description

leetcode504的更多相关文章

  1. [Swift]LeetCode504. 七进制数 | Base 7

    Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202&q ...

  2. Leetcode504.Base 7七进制数

    给定一个整数,将其转化为7进制,并以字符串形式输出. 示例 1: 输入: 100 输出: "202" 示例 2: 输入: -7 输出: "-10" 注意: 输入 ...

随机推荐

  1. bulid-tool

    Build tool 中文构建工具.构建工具能够帮助你创建一个可重复的.可靠的.携带的且不需要手动干预的构建.构建工具是一个可编程的工具,它能够让你以可执行和有序的任务来表达自动化需求.假设你想要编译 ...

  2. ballerina 学习 三十一 扩展开发(二)

    上篇说了使用ballerina 语言开发扩展模块,对于注解类型的我们是需要使用java 语言进行 开发的 官方提供了一个hello 的demo可以参考 https://github.com/balle ...

  3. stenciljs 学习九 使用jsx

    可以使用jsx 方便组件的开发 基本格式 主要是render 函数 class MyComponent { render() { return ( <div> <h1>Hell ...

  4. win7上搭建Android环境及调试

    工欲善其事必先利其器,好记性不如烂笔头.要学习一门新的语言,首先必须得先搭环境,否则没法实践.如果之前按照网上的提示,搭建过环境,而且环境比较复杂的话,我相信隔很长一段时间后,就会忘记,到真正用的时候 ...

  5. 利用阿里巴巴封装的FastJSON来解析json并转换成map

    利用阿里巴巴封装的FastJSON来解析json并转换成map   package com.zkn.newlearn.json; import com.alibaba.fastjson.JSON; i ...

  6. 【转】每天一个linux命令(55):traceroute命令

    原文网址:http://www.cnblogs.com/peida/archive/2013/03/07/2947326.html 通过traceroute我们可以知道信息从你的计算机到互联网另一端的 ...

  7. 【转】每天一个linux命令(14):head 命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/11/06/2756278.html head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头 ...

  8. telinit:Did not receive a reply.Possible causes include:the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired

    问题: Enabling /etc/fstab swaps: [ok]telinit:Did not receive a reply.Possible causes include:the remot ...

  9. react-router4.0的使用

    近来很忙,学了一波react,特来记一笔,分享下react-router的使用方式 第一步引入内部组件 import {Route,BrowserRouter as Router,Switch,Lin ...

  10. protobuf 协议 windows 下 C++ 环境搭建

    1. 下载protobuf https://code.google.com/p/protobuf/downloads/list Protocol Buffers 2.5.0 full source - ...