Determinar un algoritmo que permita convertir un número arábigo comprendido entre 1 y 99 a números romanos
Solución
- Entrada: 97
- Salida: XCVII
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N, u, d As Integer Dim Unidad() As String = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"} Dim Decena() As String = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"} N = TextBox1.Text If (N >= 10) Then u = N Mod 10 d = Math.Floor(N / 10) TextBox2.Text = Decena(d) + Unidad(u) Else TextBox2.Text = Unidad(N) End If End Sub End Class
0 comentarios:
Publicar un comentario