English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

雖然讀資訊但對程式設計真的是覺得好難,老師出得問題我實在是真的一知半解,只好請教程設高手幫幫我
用Visual Basic應用程式新增
1.Min()和Max()函數,函數傳入3個整數參數,傳回值分別是參數的最小和最大值
2.Sum()和Average()函數,共五個參數,可計算參數成績資料總分與平均值
老師說很簡單,但我對程式設計不知怎的就是搞不懂,頭都痛了.........唉.......救救我

2006-12-27 15:08:07 · 1 個解答 · 發問者 布丁 2 in 電腦與網際網路 程式設計

1 個解答

是很簡單 你可能真的要多多練習
如果有問題, 請來函討論. 不然, 我可能會錯失你再補充的疑點.

Public Function Min(a As Integer, b As Integer, c As Integer) As Integer

If (a > b) Then
Min = b
Else
Min = a
End If
If (c < Min) Then
Min = c
End If

End Function


Public Function Max(a As Integer, b As Integer, c As Integer) As Integer

If (a < b) Then
Max = b
Else
Max = a
End If
If (c > Max) Then
Max = c
End If

End Function


Public Function Sum(a As Integer, b As Integer, c As Integer, d As Integer, e As Integer) As Integer

Sum = a + b + c + d + e

End Function


Public Function Average(a As Integer, b As Integer, c As Integer, d As Integer, e As Integer) As Single

Average = Sum(a, b, c, d, e) / 5

End Function

2006-12-28 08:02:35 · answer #1 · answered by JJ 7 · 0 0

fedest.com, questions and answers