// Dup1 prints the text of each line that appears more than
// once in the standard input, preceded by its count.
package main

import (
	"bufio"
	"fmt"
	"os"
)

func DUP1() {
	fmt.Printf("----------dup1 start ---------------")
	counts := make(map[string]int) //映射，key是string、value是int
	input := bufio.NewScanner(os.Stdin)  //读取 终端输入
	fmt.Printf("please input:\n")
	for input.Scan() && input.Text() != "end!" {
		counts[input.Text()]++
		// fmt.Printf("value:%s\n", input.Text())
	}
	// NOTE: ignoring potential errors from input.Err()
	fmt.Printf("\ninput end!\n")
	for line, n := range counts {
		// if n > 1 {
		fmt.Printf("%d\t%s\n", n, line)
		// }
	}
	fmt.Printf("----------dup1 end ---------------")
}
