# 02 Golang 打印九九乘法表 **Published by:** [Robin](https://paragraph.com/@robin-8/) **Published on:** 2023-02-22 **URL:** https://paragraph.com/@robin-8/02-golang ## Content for循环实现// for嵌套循环打印九九乘法口诀 package main import "fmt" func main() { for x := 1; x <= 9; x++ { for y := 1; y <= 9; y++ { if y > x { continue } fmt.Printf("%d * %d = %d\t", y, x, x*y) } fmt.Println() } } 多维数据实现// 通过 Go 语言的多维数组打印出九九乘法 func main() { var multi [9][9]string for j := 0; j < 9; j++ { for i := 0; i < 9; i++ { n1 := i + 1 n2 := j + 1 if n1 > n2 { continue } multi[j][i] = fmt.Sprintf("%d x %d = %d", n1, n2, n1*n2) } } for _, v1 := range multi { for _, v2 := range v1 { fmt.Printf("%s\t", v2) } fmt.Println() } } ## Publication Information - [Robin](https://paragraph.com/@robin-8/): Publication homepage - [All Posts](https://paragraph.com/@robin-8/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@robin-8): Subscribe to updates