1 for循环语句的例子
//定义一个分数
var score=80;
//定义一个数组
var scores=[90,98];
var minScord=0;
var maxscore=0;
var avgscore=0.0;
var count=scores.count;
var sumscore=0.0;
//循环数组中所有数据
for s inscores
{
println("s is \(s)");
}
println("sumscore is\(sumscore)")
2 do while 循环语句例子
var index=0;
do{
var s=scores[index]
index++
println(s)
}while(index<count)
3 while 循环语句
while (index<count)
{
var ss=scores[index]
println("while s\(ss)")
}
//switch切换语句
let appType = "IOS"
switch appType {
case "IOS":
println("IOS开发");
fallthrough;//不让往下走
case "ANdroid":
println("Android开发")
case "windowPhhone":
println("WIndow Phone")
default:
break;
};
1 for循环语句的例子 //定义一个分数 var score=80; //定义一个数组 var scores=[90,98]; var minScord=0; var maxscore=0; var avgscore=0.0; var count=scores.count; var sum 原文链接:https://www.f2er.com/swift/326063.html