-6
爲什麼此函數會打印出[83 83 83 83 83]
而不是[98 93 77 82 83]
?Go中的嵌套循環陣列行爲不像其他語言的陣列
package main
import "fmt"
func main() {
var x [5]float64
scores := [5]float64{ 98, 93, 77, 82, 83, }
for i, _ := range x {
for j, _ := range scores {
// fill up x array with elements of scores array
x[i] = scores[j]
}
}
fmt.Println(x)
}
該劇的鏈接似乎是世界你好。 – ams 2014-09-24 13:39:28
@ams我已修復play.golang.org鏈接 – VonC 2014-09-24 13:41:55
謝謝你的明確答案。 – PieOhPah 2014-11-30 22:08:13