4 Star 25 Fork 17

编程语言算法集 / Go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
combination.go 592 Bytes
一键复制 编辑 原始数据 按行查看 历史
// Package combination ...
package combination
import "fmt"
// Combinations structure with in and out rune
type Combinations struct {
out []rune
in []rune
}
// Start ...
func Start(input string) {
c := &Combinations{
in: []rune(input),
}
c.Combine(0)
}
// Combine ...
func (c *Combinations) Combine(seed int) {
inLen := len(c.in)
for i := seed; i < inLen-1; i++ {
c.out = append(c.out, c.in[i])
fmt.Println(string(c.out))
c.Combine(i + 1)
c.out = c.out[:len(c.out)-1]
}
c.out = append(c.out, c.in[inLen-1])
fmt.Println(string(c.out))
c.out = c.out[:len(c.out)-1]
}
Go
1
https://gitee.com/TheAlgorithms/Go.git
git@gitee.com:TheAlgorithms/Go.git
TheAlgorithms
Go
Go
master

搜索帮助