go语言,创建一个程序, 要求能够打印类似下面的结果( 直到每行 25 个字符时为止) : 1. G 2. GG 3. GGG 4. GGGG 5. GGGGG 6. GGGGGG
时间: 2024-06-03 10:09:02 浏览: 65
package main
import "fmt"
func main() {
count := 1
for {
for i := 0; i < count; i++ {
fmt.Print("G")
}
if count%5 == 0 {
fmt.Println()
}
if count == 30 {
break
}
count++
}
}
// Output:
// G
// GG
// GGG
// GGGG
// GGGGG
// GGGGGG
// GGGGGGG
// GGGGGGGG
// GGGGGGGGG
// GGGGGGGGGG
// GGGGGGGGGGG
// GGGGGGGGGGGG
// GGGGGGGGGGGGG
// GGGGGGGGGGGGGG
// GGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGGGGGGG
// GGGGGGGGGGGGGGGGGGGGGGGGGGGGG
阅读全文