Hacer un programa o algoritmo que si se ingresan 5 notas de un alumno, publicar las 2 peores notas
Solución
- Entrada: 15, 10, 13, 8,19
- Salida: 10, 8
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim u As Integer = 0 Dim tem As Integer Dim Nota(5) As Integer Nota(0) = TextBox1.Text Nota(1) = TextBox2.Text Nota(2) = TextBox3.Text Nota(3) = TextBox4.Text Nota(4) = TextBox5.Text While (u <> 4) u = 0 For k As Integer = 0 To 3 If (Nota(k) <= Nota(k + 1)) Then u = u + 1 Else tem = Nota(k) Nota(k) = Nota(k + 1) Nota(k + 1) = tem End If Next k End While TextBox6.Text = "Las 2 peores notas obtenidas son: " + Trim(Nota(0)) + " y " + Trim(Nota(1)) End Sub End Class
0 comentarios:
Publicar un comentario