import Foundation
//生成随机数(十位数)然后求余
var randoma = arc4random();
print(randoma)
//1...50的随机数
var randomb = randoma % 50
print(randomb)
if randomb == 0 {
print("The num is 50")
} else {
print("The num is \(randomb)")
}
//直接生成1...100的一个随机数
let temprandom = Int(arc4random_uniform(100)) + 1
print(temprandom)
结果:
3982032407
7
The num is 7
11
Program ended with exit code: 0