add some new examples

This commit is contained in:
Илья Смышляев 2022-09-16 01:40:14 +04:00
parent 6e5b860955
commit 3683bdf7c2
5 changed files with 13 additions and 36 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,35 +0,0 @@
package main
import "fmt"
func main() {
// for i := 1; i < 101; i++ {
// if i%15 == 0 {
// fmt.Print("FizzBuzz\n")
// } else if i%3 == 0 {
// fmt.Print("Fizz\n")
// } else if i%5 == 0 {
// fmt.Print("Buzz\n")
// } else {
// fmt.Println(i)
// }
// }
switchFB()
}
func switchFB() {
for i := 1; i < 101; i++ {
switch {
case i%15 == 0:
fmt.Println("FizzBuzz")
case i%3 == 0:
fmt.Println("Fizz")
case i%5 == 0:
fmt.Println("Buzz")
default:
fmt.Println(i)
}
}
}

BIN
fizzbuzz/.DS_Store vendored Normal file

Binary file not shown.

2
go.mod
View File

@ -1,3 +1,3 @@
module gotest/fizzbuzz module gotest
go 1.19 go 1.19

12
rotation/rotation.go Normal file
View File

@ -0,0 +1,12 @@
package rotation
func Rotation(A []int, K int) []int {
for i := 0; i < K; i++ {
//A[len(A)-1: - последний элемент; A[:len(A)-1] - все элементы до последнего
A = append(A[len(A)-1:], A[:len(A)-1]...)
}
return A
}