swift 循环 for while
发布时间:2020-12-14 06:39:26 所属栏目:百科 来源:网络整理
导读:循环语句 // main.swift// L001for//// Created by hins on 16/10/26.// Copyright ? 2016年 hins. All rights reserved.//import Foundationprint("Hello,World!")//循环//数组循环var arr:[Int] = Array();for item in 1...100{ arr.append(item); //print
循环语句 // main.swift // L001for // // Created by hins on 16/10/26. // Copyright ? 2016年 hins. All rights reserved. // import Foundation print("Hello,World!") //循环 //数组循环 var arr:[Int] = Array(); for item in 1...100{ arr.append(item); //print("=======") } print(arr.count) for (i,value) in EnumerateSequence(arr){ print("(i+1)======(value)"); } var n=0; while n<arr.count{ print("(n),(arr[n])"); n = n+1; } //字典循环 var dict:Dictionary<Int,String> = Dictionary(); for i in 1...10{ dict[i]="aaa(i)"; } for (key,value) in dict{ print("(key),(value)"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |