1. 写一个程序,统计一个字符串中每个单词出现的次数。比如:”how do you do”中how=1 do=2 you=1。
代码如下:
package main
import (
"fmt"
"strings"
)
func main() {
s := "how do you do"
fmt.Println(WordCount(s))
}
func WordCount(s string) map[string]int {
//return map[string]int{"x": 1}
m