问题描述
- 正在自学go语言,命令行执行以下程序,进入等待输入状态,请问如何处理?
- package main
import (
bufio""
fmt""
os""
)func main() {
counts := make(map[string]int)
input := bufio.NewScanner(os.Stdin)
for input.Scan() {
counts[input.Text()]++
}
// NOTE: ignoring potential errors from input.Err()
for line n := range counts {
if n > 1 {
fmt.Printf(""%dt%sn"" n line)
}
}
}
时间: 2024-10-08 14:07:44