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

Commit 972ca2d

Browse files
authored
Update kama55.右旋字符串.md
1 parent bb66452 commit 972ca2d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎problems/kama55.右旋字符串.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,34 @@ public class Main {
214214

215215

216216
### Go:
217+
```go
218+
package main
219+
import "fmt"
220+
221+
func reverse (strByte []byte, l, r int){
222+
for l < r {
223+
strByte[l], strByte[r] = strByte[r], strByte[l]
224+
l++
225+
r--
226+
}
227+
}
228+
229+
230+
func main(){
231+
var str string
232+
var target int
233+
234+
fmt.Scanln(&target)
235+
fmt.Scanln(&str)
236+
strByte := []byte(str)
237+
238+
reverse(strByte, 0, len(strByte) - 1)
239+
reverse(strByte, 0, target - 1)
240+
reverse(strByte, target, len(strByte) - 1)
241+
242+
fmt.Printf(string(strByte))
243+
}
244+
```
217245

218246

219247
### JavaScript:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /