Ejercicio
Función mayor valor en una matriz
Objetivo
Cree una función que devuelva el mayor valor almacenado en una matriz de números reales que se especifique como parámetro:
float[] data={1.5f, 0.7f, 8.0f}
float max = Máximo(datos);
Código
Imports System
Public Class exercise118
Private Shared Sub Main(ByVal args As String())
Dim data As Single() = {1.5F, 0.7F, 8.0F}
Dim max As Single = Maximum(data)
Console.WriteLine(max)
End Sub
Private Shared Function Maximum(ByVal list As Single()) As Single
Dim max As Single = -99999999.00F
For i As Integer = 0 To list.Length - 1
If i = 0 Then
max = list(i)
Else
max = If(max < list(i), list(i), max)
End If
Next
Return max
End Function
End Class