Triángulo, Noreste Aprende programación con ejercicios Visual Basic (VB.net)

Lección:

Tipos de datos básicos


Ejercicio:

Triángulo, Noreste 49


Objetivo:

Escriba un programa en Visual Basic (VB.net) que solicite un ancho y muestre un triángulo como este:

Introduzca el ancho deseado: 5

*****
_****
__***
___**
____*


Código:

Imports System
Public Class exercise62
    Public Shared Sub Main()
        Dim width, height As Integer
        Dim row, column As Integer
        Dim max As Integer
        Console.Write("Enter the desired width: ")
        height = Convert.ToInt32(Console.ReadLine())
        width = 0
        max = height

        For row = 0 To height - 1

            For column = 0 To width - 1
                Console.Write(" ")
            Next

            For asterisks As Integer = 0 To max - 1
                Console.Write("*")
            Next

            Console.WriteLine()
            width += 1
            max -= 1
        Next
    End Sub
End Class