#13公式計算,比方寫梯形面積的 function
Published in
Aug 10, 2022
Target: 在playground建立Function與型別
寫出梯形面積計算function解出下面三題梯形面積
func trapezoidArea(topline: Double, baseline: Double, height: Double) {
let Area = (topline + baseline) * height / 2
print(Area)
}trapezoidArea(topline: 4, baseline: 6, height: 5)
trapezoidArea(topline: 3, baseline: 5, height: 2)
trapezoidArea(topline: 3, baseline: 7, height: 4)
答案正確