Pages

jueves, 24 de enero de 2013

Calcular el número mayor de una lista de números Codigo Fuente en Visual Basic

Problema
Hacer un programa o algoritmo que permita calcular el número mayor de una lista de números

Codigo Fuente en Visual Basic
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim Num(10) As Integer
        Dim ale As Integer = 0
        Dim may As Integer = -10000
        Dim cad As String = ""
        For i As Integer = 0 To 10
            Randomize()
            ale = CInt(Int((150 * Rnd()) + 1))
            Num(i) = ale
            cad = cad + " " + Trim(ale)
        Next i
        TextBox1.Text = cad
        For j As Integer = 0 To 10
            If (Num(j) > may) Then
                may = Num(j)
            End If
        Next j
        TextBox2.Text = "El mayor es: " + Trim(may)
    End Sub
End Class

0 comentarios:

Publicar un comentario en la entrada