Get the App
SLTechnology News&Howtos  ›  Development  › 

An example Analysis of Go Array element access

Shulou Source: shulou.com Published: 2022-06-01 02:31:34 10月15日 Update

This article focuses on "Go array element access case analysis", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "Go array element access case analysis" bar!

Package main

Import "fmt"

Func main () {

Var i,j,k int

/ / quickly initialize the array while declaring the array

Balance: = [5] float32 {1000.0, 2.0,3.4,7.0,50.0}

/ * output array elements * /.

For I = 0; I < 5; iTunes + {

Fmt.Printf ("balance [% d] =% f\ n", I, balance [I])

}

Balance2: = [...] float32 {1000.0, 2.0,3.4,7.0,50.0}

/ * output the value of each array element * /

For j = 0; j < 5; jacks + {

Fmt.Printf ("balance2 [% d] =% f\ n", j, balance2 [j])

}

/ / initialize elements with indexes 1 and 3

Balance3: = [5] float32 {1VOR 2.0JT 3JR 7.0}

For k = 0; k < 5; kink + {

Fmt.Printf ("balance3 [% d] =% f\ n", k, balance3 [k])

}

}

The execution result of the above example is as follows:

Balance [0] = 1000.000000balance [1] = 2.000000balance [2] = 3.400000balance [3] = 7.000000balance [4] = 50.000000balance2 [0] = 1000.000000balance2 [1] = 2.000000balance2 [2] = 3.400000balance2 [3] = 50.000000balance3 [0] = 0.000000balance3 [1] = 2.000000balance3 [2] = 0.000000balance3 [3] = 7.000000balance3 [4] = 0.000000 I believe that you have a deeper understanding of "Go array element access instance analysis". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Arrays elements examples instance analysis analysis content learning output practicality deeper interest at the same time practicality practicality simplicity of operation methods more friends indexes results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux MySQL Huawei Docker