码迷,mamicode.com
首页 > 其他好文 > 详细

go06 for循环。

时间:2019-06-10 18:50:48      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:print   fun   class   pre   main   style   UNC   for循环   div   

有限循环

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
}
}

}


 

go06 for循环。

标签:print   fun   class   pre   main   style   UNC   for循环   div   

原文地址:https://www.cnblogs.com/paad/p/10999369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!