(很急的)編寫一個三個數中最大值max和最小值min的過程
題目:
(很急的)編寫一個三個數中最大值max和最小值min的過程
編寫一個三個數中最大值max和最小值min的過程,然後用這個過程分別求3個數和5個數,7個數中的最大值和最小值.
解答:
Private Function Ma(n1 As Double,n2 As Double,n3 As Double) As Double
Ma = IIf(n1 > n2,n1,n2)
Ma = IIf(Ma > n3,Ma,n3)
End Function
Private Function Mi(n1 As Double,n2 As Double,n3 As Double) As Double
Mi = IIf(n1 < n2,n1,n2)
Mi = IIf(Mi < n3,Mi,n3)
End Function
然後調用
添加新評論