//: Playground - noun: a place where people can play
import UIKit
// 第一:声明一个变量
var str = "Hello,成功QQ吧"
// 第二:做加法运算
var Sum :Int = 0
for index in 1...100 {
Sum = Sum + index
print(Sum)
}
// 第三:做减法运算
var Sub :Int = 100
for i in 1...100{
Sub - i
print(Sub - i)
}
// 自增加运算
var i = 0
var k = 0
for j in 1...5{
++i
print(i)
k++
print(k)
}
var image = UIImageView(image: UIImage(named: "ef8aa6c32b8d683b6afd918ac43f99ca.jpg"))
image.layer.masksToBounds = true
image.layer.cornerRadius = CGFloat(50)
image
// 调试一个函数,判断是否是水仙花数
func JionNumber(Number:Int)->Bool{
let tempNumber:NSString = String(Number)
let AllCount = tempNumber.lengthOfBytesUsingEncoding(4)
var sum = 0
for (var i = 0 ; i < AllCount; i++) {
let Threetemp :NSString = tempNumber.substringWithRange(NSMakeRange(i,1))
sum = sum + Int(pow(Threetemp.doubleValue,3))
}
return sum == Number ? true : false
}
JionNumber(153)
// 计算 100 -- 200 键的水仙花数
for i in 100...400{
if JionNumber(i){
i
}
}