龚成明 2 年之前
父节点
当前提交
600f0ed392
共有 5 个文件被更改,包括 26 次插入0 次删除
  1. 0 0
      chapter01/01/helloworld.go
  2. 0 0
      chapter01/02/echo1.go
  3. 0 0
      chapter01/02/echo2.go
  4. 0 0
      chapter01/02/echo3.go
  5. 26 0
      chapter01/03/dup1.go

+ 0 - 0
chapter01/helloworld.go → chapter01/01/helloworld.go


+ 0 - 0
chapter01/echo1.go → chapter01/02/echo1.go


+ 0 - 0
chapter01/echo2.go → chapter01/02/echo2.go


+ 0 - 0
chapter01/echo3.go → chapter01/02/echo3.go


+ 26 - 0
chapter01/03/dup1.go

@@ -0,0 +1,26 @@
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"os"
+)
+
+func main() {
+	counts := make(map[string]int)
+	input := bufio.NewScanner(os.Stdin)
+	for input.Scan() {
+		text := input.Text()
+
+		counts[text]++
+
+		if text == "quit" {
+			break
+		}
+	}
+	for line, n := range counts {
+		if n >= 1 {
+			fmt.Printf("%d\t%s\n", n, line)
+		}
+	}
+}