登錄站點

用戶名

密碼

FindMax

3已有 1309 次閱讀  2017-04-19 00:58
   Private Sub FindMax()
        Dim vals As Integer() = {1, 4, 100, -100, 200, 4, 6}
        Dim largest As Integer = Integer.MinValue
        Dim smallest As Integer = Integer.MaxValue
        For Each element As Integer In vals
            largest = Math.Max(largest, element)
            smallest = Math.Min(smallest, element)
        Next
        MsgBox("最大:  " & largest)
        MsgBox("最小:  " & smallest)
    End Sub
分享 舉報