package main import ( "fmt" ) /* * 打印星星次数=1*2-1 =1 打印空格次数=3-1=2 *** 打印星星次数=2*2-1=3 打印空格次数=3-2=1 ***** 打印星星次数=3*2-1=5 打印空格次数= 3-3=0 */ func main() { totallevle := 5 for i := 1; i <= totallevle; i++ { for k := 1; k <= totallevle-i; k++ { fmt.Print(" ") } for j := 1; j <= 2*i-1; j++ { fmt.Print("*") } fmt.Println() } }