1. 程式人生 > >Golang反轉數組

Golang反轉數組

golang

package main import ( "fmt" ) func main() { ints := []int{1, 2, 3} fmt.Printf("%v\n", ints) for i, j := 0, len(ints)-1; i < j; i, j = i+1, j-1 { ints[i], ints[j] = ints[j], ints[i] } fmt.Printf("%v\n", ints) }

Golang反轉數組