Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite198f8f

Browse files
committed
add new files
1 parentee123d1 commite198f8f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎504. Base 7.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import"strconv"
4+
5+
funcconvertToBase7(numint)string {
6+
ifnum==0 {
7+
return"0"
8+
}
9+
ret:=""
10+
flag:=false
11+
ifnum<0 {
12+
flag=true
13+
num=-num
14+
}
15+
fornum>0 {
16+
a:=num%7
17+
ret=strconv.Itoa(a)+ret
18+
num=num/7
19+
}
20+
ifflag {
21+
ret="-"+ret
22+
}
23+
returnret
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp