-
利用NSString,去掉字符串中的部分字符集查看全部
-
NSString查看全部
-
精度控制,占位符?查看全部
-
趋于人类自然语言解析方式,不关注底层实现查看全部
-
对比c语言,汉字是2个character。。 在swift中,依然是一个character,但是底层实现依然是2个character查看全部
-
case 与where匹配使用,作为if 判断语句查看全部
-
给循环取名字查看全部
-
case(let x,0):<br> 将第一维度的值赋予x,可以在statement中取到该值查看全部
-
类似模式匹配查看全部
-
value://can be 区间,不仅仅单值查看全部
-
case value://value can be int ,float,bool,string,also can be more than one value here<br> //at least one executable statement<br> //break is not necessary查看全部
-
import UIKit //x^4 - y^2 = 15*x*y awsq:for m in 1...300{ for n in 1...300{ if m*m*m*m - n*n == 15*m*n{ print("\(m) , \(n)") break awsq } } }查看全部
-
import UIKit while true{ var a = arc4random_uniform(6) + 1 var b = arc4random_uniform(6) + 1 if a == b { print("平局") continue } var win = a > b ? "A" : "B" print("A is \(a) , B is \(b) , \(win) is win!") break }查看全部
-
import UIKit var awin = false var bwin = false var game = 0 repeat{ game++ var a = arc4random_uniform(3) + 1 var b = arc4random_uniform(3) + 1 print("a is \(a) , b is \(b)" , terminator:",") if a < b { bwin = true }else if a > b { awin = true }else{ print("平局") awin = false bwin = false } }while !awin && !bwin let win = awin ? "awin" : "bwin" print("game is \(game) , \(win) is win!")查看全部
-
var awin = 0 var bwin = 0 var game = 0 while awin < 3 && bwin < 3 { game++ var a = arc4random_uniform(10) + 1 var b = arc4random_uniform(10) + 1 print("a is \(a) , b is \(b): " , terminator:"") if a < b { print("bwin!") bwin++ awin = 0 }else if a > b { print("awin!") awin++ bwin = 0 }else{ print("平局") awin = 0 bwin = 0 } } let win = awin == 3 ? "awin" : "bwin" print("game is \(game) , awin is \(awin) , bwin is \(bwin) , \(win) is win!")查看全部
举报
0/150
提交
取消