package main import "fmt" func main(){ myArray := [10]int{1,2,3,4,5,6,7,8,9,10} var mySplic [] int = myArray[:5] my_array := make( []int,10,20) my_array2 := make([]int,5,10) my_array3 :=[] int{1,2,3,5,100} for x,y := range my_array3{ my_array2[x] = y if x == 0{ fmt.Println("no") my_array2[x] = 22 } fmt.Println("x:y",x,y) } for x,y := range myArray{ fmt.Println("MyArray x,y:",x,y) my_array[x] = y } fmt.Println("my_array:", my_array3) fmt.Println(mySplic) fmt.Println(myArray) for _, v := range myArray { fmt.Println(v," ") } for i, v := range mySplic{ fmt.Println(i,v) } copy(my_array,my_array2) fmt.Print("my_array2:",my_array2) fmt.Println("my_array:",my_array) fmt.Print("/n") }
时间: 2024-11-07 07:40:45