FindMax
熱3已有 1427 次閱讀 2017-04-19 00:58 Private Sub FindMax()
Dim vals As Integer() = {1, 4, 100, -100, 200, 4, 6}
Dim vals As Integer() = {1, 4, 100, -100, 200, 4, 6}
Dim largest As Integer = Integer.MinValue
Dim smallest As Integer = Integer.MaxValue
Dim smallest As Integer = Integer.MaxValue
For Each element As Integer In vals
largest = Math.Max(largest, element)
smallest = Math.Min(smallest, element)
Next
largest = Math.Max(largest, element)
smallest = Math.Min(smallest, element)
Next
MsgBox("最大: " & largest)
MsgBox("最小: " & smallest)
End Sub
MsgBox("最小: " & smallest)
End Sub
發表評論 評論 (0 個評論)