求助啊 关于2,3,4,5过滤问题求助

hellsam · · 788 次点击
```go import ( "log" "strings" ) func main() { strDealWith() } func strDealWith() { form := "2,4,55,70" sql := "2,4,6,9" f := strings.Split(form, ",") s := strings.Split(sql, ",") h := HasData(f, s) r:= NoData(s,h) log.Println(r) } func HasData(source, res []string) []string { nn := make([]string, 0) if len(source) > 0{ for _,v :=range source{ b := IsContain(res, v) if b{ nn = append(nn,v) } } } return nn } func NoData(source, res []string) []string { nn := make([]string, 0) if len(source) > 0{ for _,v :=range source{ b := IsContain(res, v) if !b{ nn = append(nn,v) } } } return nn } func IsContain(items []string, item string) bool { for _, eachItem := range items { if eachItem == item { return true } } return false } ```
#5
更多评论
建议你重新组织一下语言,先把问题理顺了再提问,不然真不好看明白你要干嘛
#1
估计是笔试题现场的紧急召唤
#2