数组内任一两位数字组合成不重复的数组
var arr = []int{14, 13, 12, 11, 9, 8, 6, 4, 2}
[14,13]和[13,14]就算重复

package main

import (
    "fmt"
)

func main() {
    s := make([]int, 2)
    var arr = []int{14, 13, 12, 11, 9, 8, 6, 4, 2}

    for i := 1; i < len(arr); i++ {
        s[0] = arr[i-1]
        var winArr []int
        winArr = append(winArr, arr[i:]...)

        for j := 0; j < len(winArr); j++ {
            s[1] = winArr[j]
            fmt.Println(s)
        }
    }
}

标签: none

添加新评论