数组 ##数组的定义与赋值: 1. var num [3]int num = [3]int{1,2,3} 2. var num [3]int = [3]int {1,2,3} 3. num := [3]int{1,2,3} 4. num :=[...]int{1,2,3} 5. num :=[...]int{4:20,7:11} //定义下表为4的值是20,下表为7的值是11 切片 切片的定义与赋值: 1. primes := [8]int{1,2,3,4,5,6,7,8} //先定义赋值出一个…
1. 数组1.1 如何定义数组同java数组一样,数组是一组内存连续且类型相同的数据组成 //不初始化初始值默认为0 var arr1 = [5]int{} var arr2 = [5]int{1,2,3,4,5} //声明数组下标3的值为10 var arr3 := [3:10] arr4 := []int{1,2,3,4,5} //操作数据 for i := 0; i < len(arr1); i++ { arr1[i] = i * 10 } for index, value := rang…