乘法口訣ide
func main() { for i := 1; i <= 9; i++ { for j := 1; j <= i; j++ { fmt.Printf("%d*%d=%d\t", i, j, i*j) } fmt.Println("") } }
菱形code
func main() { for i := 1; i <= 9; i++ { for a := 9; a > i; a-- { fmt.Printf(" ") } for j := 1; j <= i; j++ { fmt.Printf(" *") } fmt.Println("") } for b := 8; b >= 1; b-- { for c := 9; c > b; c-- { fmt.Printf(" ") } for d := 1; d <= b; d++ { fmt.Printf(" *") } fmt.Println("") } }