package main import "fmt" func printPatternIterative(n int) { for i := 1; i <= n; i++ { // 打印当前层的数字 for j := 0; j < i; j++ { fmt.Printf("%d ", i) } fmt.Println() } } func main() { fmt.Println("非递归算法:") printPatternIterative(5) }