go语言for循环的三种写法
func main() {
a := []string{}
a = append(a, "hello")
a = append(a, ", ")
a = append(a, "world")
fmt.Println(a)
for i := 0; i < len(a); i++ {
fmt.Println(a[i])
}
for _, aa := range a {
aa += "@"
fmt.Println(aa)
}
for i :=0;i<len(a);i++ {
a[i] += "@"
fmt.Println(a[i])
}
fmt.Println(a)
}
打印99 乘法表
func main() {
for i :=1;i<=9;i++{
for j:=1;j<=i;j++{
fmt.Printf("%d*%d=%d ",i,j,i*j)
}
fmt.Println()
}
}
本文来自博客园,作者:Chuan_Chen,转载请注明原文链接:https://www.cnblogs.com/wangcc7/p/12873397.html