func getMean(value:Double ...) -> Double { var all:Double = 0 // 把变长参数当数组使用 for num in value { all += num } return all / Double(value.count) } getMean(1,2,3,4,5,6,54) getMean(1,6) getMean(1,54)
func getMean(value:Double ...) -> Double { var all:Double = 0 // 把变长参数当数组使用 for num in value { all += num } return all / Double(value.count) } getMean(1,2,3,4,5,6,54) getMean(1,6) getMean(1,54)