Ejercicio
Triángulo centrado
Objetivo
Mostrar un triángulo centrado a partir de una cadena introducida por el usuario:
__a__
_uan_
Juan
Código
Imports System
Public Class exercise85
Public Shared Sub Main()
Dim name As String
Console.Write("Enter your name: ")
name = Console.ReadLine()
If name.Length Mod 2 = 0 Then name += " "
Dim position As Integer = name.Length / 2
Dim maxRows As Integer = name.Length / 2 + 1
Dim amount As Integer = 1
For i As Integer = 0 To maxRows - 1
For j As Integer = 0 To position - 1
Console.Write(" ")
Next
Console.WriteLine(name.Substring(position, amount))
position -= 1
amount += 2
Next
End Sub
End Class