Chức năng: Tìm phần tử có giá trị lớn nhất trong mảng số nguyên
Ngôn ngữ: asp - Nhóm: array
CÚ PHÁP
intMax = MaxValOfIntArray(TheArray)
Hàm trả về giá trị lớn nhất của một mảng số nguyên.
VÍ DỤ
<%
Dim theArray
theArray = Array(1, 5, 56, 45, 33)
response.write MaxValOfIntArray(TheArray)
'--- returns: 56
%>
ASP Code
<%
Public Function MaxValOfIntArray(ByRef TheArray)
'--- This function gives max value of int array without sorting an array
Dim i
Dim MaxIntegersIndex
MaxIntegersIndex = 0
For i = 1 To UBound(TheArray)
If TheArray(i) > TheArray(MaxIntegersIndex) Then
MaxIntegersIndex = i
End If
Next
'--- index of max value is MaxValOfIntArray
MaxValOfIntArray = TheArray(MaxIntegersIndex)
End Function
%>