package main
import "fmt"
func main() {
var pow = []int{1, 2, 4, 8, 16, 32}
for index, value := range pow {
fmt.Printf("2**%d = %d\n", index, value)
}
}
2**0 = 1
2**1 = 2
2**2 = 4
2**3 = 8
2**4 = 16
2**5 = 32
package main
import "fmt"
func main() {
var pow = []int{1, 2, 4, 8, 16, 32}
for index, value := range pow {
fmt.Printf("2**%d = %d\n", index, value)
}
}
2**0 = 1
2**1 = 2
2**2 = 4
2**3 = 8
2**4 = 16
2**5 = 32
本文标题:Go array range
本文链接:https://www.haomeiwen.com/subject/qkmrpqtx.html
网友评论