I recently started to learn Go. I have a task from JetBrains: "Declare a three-dimensional array of the float32 type with the size of 4 by 4 by 4 elements, assign 88.6 to its [1][0][2] element, and finally print the array to the console." I declared an array like this:
var array = [4][4][4]float32{}
Now i have few problems:
I hope my question is clear!
I think the task is asking you to assign to only one element in the array:
package main
import "fmt"
func main() {
var array [4][4][4]float32
array[1][0][2] = 88.6
fmt.Println(array)
}
Output:
[[[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]] [[0 0 88.6 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.