标签:style class blog code color for
用了while, do...while, for in, for in ...
var i = 0 var temp = 0 while i < 1000 { temp += i i++ } println(temp) var j = 0 var temp2 = 0 do { temp2 += j j++ } while (j < 1000) println(temp2) var temp3 = 0 for a in 0...999 { temp3 += a } println(temp3) var temp4 = 0 for var b = 0; b < 1000; b++ { temp4 += b; } println(temp4)
swift从0加到1000(不包括1000)的四种写法,布布扣,bubuko.com
标签:style class blog code color for
原文地址:http://www.cnblogs.com/skiy/p/3806410.html