package main
//不知道错在哪里
import (
"fmt"
)
func process_s(str []byte, i int, res []byte) {
if i == len(str) {
fmt.Println(res)
return
}
var reskeep []byte
copy(reskeep, res)
reskeep = append(reskeep, str[i])
process_s(str, i+1, reskeep)
var resNoInclude []byte
copy(resNoInclude, res)
process_s(str, i+1, resNoInclude)
}
func function(str string) {
Array := []byte(str)
process_s(Array, 0, make([]byte, 10))
}
func main() {
function("abc")
}
正确的输出应该是:
abc
ab
ac
a
bc
b
c
可是这段代码输出
c
c
c
c
刚刚接触golang语言有点不太明白为什么会这样,希望有人可以帮助解答