push all exercices
This commit is contained in:
BIN
ch4/2/ch4_2.exe
Normal file
BIN
ch4/2/ch4_2.exe
Normal file
Binary file not shown.
26
ch4/2/ch4_2.go
Normal file
26
ch4/2/ch4_2.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func main() {
|
||||
const numElems = 10
|
||||
randSlice := make([]int64, numElems)
|
||||
for i := 0; i < numElems; i++ {
|
||||
randSlice[i] = rand.Int63n(100)
|
||||
}
|
||||
for _, v := range randSlice {
|
||||
if v%6 == 0 {
|
||||
fmt.Println("Six!")
|
||||
} else if v%2 == 0 {
|
||||
fmt.Println("Two!")
|
||||
} else if v%3 == 0 {
|
||||
fmt.Println("Three!")
|
||||
} else {
|
||||
fmt.Println("Never mind")
|
||||
}
|
||||
}
|
||||
fmt.Println(randSlice)
|
||||
}
|
||||
3
ch4/2/go.mod
Normal file
3
ch4/2/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module ch4_2
|
||||
|
||||
go 1.25.0
|
||||
Reference in New Issue
Block a user