package main
import(
"fmt"
)
func main(){
var a = []int32{1,2,3,4,5, 6}
fmt.Println(mix(0,1,2, a, nil))
}
func mix(i, j, k int, a []int32, result [][]int32) [][]int32 {
length := len(a)
if k <= length-1 {
result = append(result, []int32{a[i], a[j], a[k]})
k++
result = mix(i, j, k, a, result)
} else {
if j <= length - 2 {
j++
k = j + 1
result = mix(i, j, k, a, result)
} else {
if i <= length - 3 {
i++
j = i + 1
k = j + 1
result = mix(i, j, k, a, result)
}
}
}
return result
}
有疑问加站长微信联系(非本文作者)