parent
d35ee31f13
commit
107ddd881d
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
words := "how do you do !"
|
||||
splits := strings.Split(words, " ")
|
||||
dictWords := make(map[string]int, 10)
|
||||
for _, v := range splits {
|
||||
_, ok := dictWords[v]
|
||||
if !ok {
|
||||
dictWords[v] = 1
|
||||
} else {
|
||||
dictWords[v]++
|
||||
}
|
||||
}
|
||||
for k, v := range dictWords {
|
||||
fmt.Printf("%v:%v\n", k, v)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue