当前位置:网站首页>Leetcode- hex number - simple
Leetcode- hex number - simple
2022-06-13 05:49:00 【AnWenRen】
title :504 Octal number - Simple
subject
Given an integer
num, Convert it to 7 Base number , And output... As a string .
Example 1
Input : num = 100
Output : "202"
Example 2
Input : num = -7
Output : "-10"
Tips
-107 <= num <= 107
Code Java
public String convertToBase7(int num) {
StringBuilder sb = new StringBuilder();
int flag = 0;
if (num == 0)
return sb.append(0).toString();
else if (num < 0) {
flag = 1;
num = -num;
}
while (num != 0) {
sb.append(num % 7);
num /= 7;
}
if (flag == 1)
sb.append('-');
return sb.reverse().toString();
}
边栏推荐
- @Detailed explanation of propertysource usage method and operation principle mechanism
- 移动端适配方案
- Leetcode- intersection of two arrays - simple
- OpenGL Mosaic (8)
- 使用cmake交叉编译helloworld
- 使用cmake交叉編譯helloworld
- Browser screenshot method (long screenshot, node screenshot, designated area screenshot)
- [China & some provinces and cities] JSON file for offline map visualization
- Mongodb Multi - field Aggregation group by
- Interrupt processing
猜你喜欢

Difference between deviation and variance in deep learning

Sentinel series introduction to service flow restriction

Use the browser to cut the entire page (take chrome as an example)

Validation set: ‘flowable-executable-process‘ | Problem: ‘flowable-servicetask-missing-implementatio

软件测试——接口常见问题汇总

MongoDB 多字段聚合Group by

MySQL performs an inner join on query. The query result is incorrect because the associated fields have different field types.

OpenGL马赛克(八)

The reason why the process cannot be shut down after a spark job is executed and the solution

How to Algorithm Evaluation Methods
随机推荐
Agile conflicts and benefits
Shardingsphere JDBC < bind table > avoid join Cartesian product
Application virtual directory static resource configuration on tongweb
Leetcode- intersection of two arrays - simple
No assessment summary
Power of leetcode-4 - simple
ffmpeg 下载后缀为.m3u8的视频文件
Etcd understanding of microservice architecture
17 servicetask of flowable task
Why do so many people hate a-spice
MySQL fuzzy query and sorting by matching degree
9. Errorstartevent and errorboundaryevent of error events
Vagrant virtual machine installation, disk expansion and LAN access tutorial
2020 personal annual summary
The reason why the process cannot be shut down after a spark job is executed and the solution
NVIDIA Jetson nano/xavier NX capacity expansion tutorial
Concurrent programming -- what is threading?
20 flowable container (event sub process, things, sub process, pool and pool)
Function and application scenario of field setaccessible() method
Config server configuration center of Nacos series