Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example Analysis of Go Array element access

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report