welcom ! Handel home

2014年7月10日 星期四

swift aobut for and while


for
var index = 0; index < 9; index++ {
    println("拍照一次!")
    println("存檔!")
}

for x in 1...10 {
    println("拍照第\(x)次!")
    println("存檔!")
}

for x in 1...10 {
     
    if(x == 5)
    {
        println("show \(x) times!")
        break;
    }
     
    println("show this \(x) !")
}
 
 
 
 
for x in 1...10 {
     
    if(x % 2 == 0)
    {
        continue;
    }
     
    println("show \(x) times!")
}



var total=0
var count=0
 
while total < 100
{
    if(count>15)
    {
        break
    }
     
    count=count+1
     
    let x:Int = (Int)(arc4random() % 10)
    println("show all = \(total) !")
     
    total = total+x
}

沒有留言: