(06) for循环。

有限循环

func main() {
    for i := 2; i <= 10; i += 2 {         //i := 2 起始条件  i<=1= 结束条件 i+=2 循环条件
        fmt.Println("好好学习", i)
    }
}
func main() {
    var count= 0
    for {
        if count%2 == 0 {
            fmt.Println("好好学习",count)
        } else {
            fmt.Println("今天撩妹",count)
        }
        count++
        time.Sleep(500*time.Microsecond)

        if count >= 11 {
            break          //跳出循环
        }

    }
}



func main() {
var count = 0
for {

if count%5 == 0 {
// 继续下次循环
continue

}

count++
fmt.Println("好好学习", count)

if count >= 21 {
break
}
}

}


 

posted @ 2019-06-10 18:10  pad+  阅读(272)  评论(0编辑  收藏  举报