push all exercices
This commit is contained in:
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)
|
||||
}
|
||||
Reference in New Issue
Block a user