dtelenkov 1 месяц назад
Родитель
Сommit
6a3ed0ad59
2 измененных файлов с 26 добавлено и 0 удалено
  1. 10 0
      books/go_head_first/misc/format.go
  2. 16 0
      books/go_head_first/misc/func.go

+ 10 - 0
books/go_head_first/misc/format.go

@@ -0,0 +1,10 @@
+package main
+
+import "fmt"
+
+func main() {
+	fmt.Println("-------------------------------")
+	fmt.Printf("%12s | %2d\n", "Stamps", 50)
+	fmt.Printf("%12s | %2d\n", "Paper Clips", 5)
+	fmt.Printf("%12s | %2d\n", "Tape", 99)
+}

+ 16 - 0
books/go_head_first/misc/func.go

@@ -0,0 +1,16 @@
+package main
+
+import (
+	"fmt"
+)
+
+func paintNeeded(width float64, height float64) {
+	area := width * height
+	fmt.Printf("%.2f liters needed\n", area/10.0)
+}
+
+func main() {
+	paintNeeded(4.2, 3.0)
+	paintNeeded(5.2, 3.5)
+	paintNeeded(5.2, 3.3)
+}