more
This commit is contained in:
parent
c6cf452643
commit
76394d4ea4
12
15-floats.go
Normal file
12
15-floats.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
x := [5]float64{ 98, 93, 77, 82, 83 }
|
||||||
|
total := 0.0
|
||||||
|
for _, v := range x {
|
||||||
|
total += v
|
||||||
|
}
|
||||||
|
fmt.Println(total / float64(len(x)))
|
||||||
|
}
|
14
16-slices.go
Normal file
14
16-slices.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
slice1 := []int{1,2,3}
|
||||||
|
slice2 := append(slice1, 4, 5)
|
||||||
|
fmt.Println(slice1)
|
||||||
|
fmt.Println(slice2)
|
||||||
|
slice3 := make([]int, 2)
|
||||||
|
copy(slice3, slice1)
|
||||||
|
fmt.Println(slice1)
|
||||||
|
fmt.Println(slice3)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user