forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a228e0
commit 6213b92
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
Retos/Reto #16 - LA ESCALERA [Media]/vbscript/arielposada.vbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
' Ejemplo de uso: | ||
' cscript arielposada.vbs 4 | ||
' Crea una función que dibuje una escalera según su número de escalones. | ||
' - Si el número es positivo, será ascendente de izquiera a derecha. | ||
' - Si el número es negativo, será descendente de izquiera a derecha. | ||
' - Si el número es cero, se dibujarán dos guiones bajos (__). | ||
' | ||
' Ejemplo: 4 | ||
' _ | ||
' _| | ||
' _| | ||
' _| | ||
' _| | ||
' | ||
' | ||
|
||
Option Explicit | ||
|
||
|
||
Function DibujarEscalera(n) | ||
Dim i | ||
If n = 0 Then | ||
WScript.Echo "__" | ||
Exit Function | ||
End If | ||
|
||
If n > 0 Then | ||
WScript.Echo String(2 * (n), " ") & "_" | ||
For i = 1 To n | ||
WScript.Echo String(2 * (n - i), " ") & "_|" | ||
Next | ||
Else | ||
n = Abs(n) | ||
WScript.Echo "_" | ||
For i = 1 To n | ||
WScript.Echo String(2 * i - 1, " ") & "|_" | ||
Next | ||
End If | ||
End Function | ||
|
||
' Lee la cadena de la línea de comandos | ||
Dim numero | ||
numero = CInt(WScript.Arguments(0)) | ||
|
||
CALL DibujarEscalera(numero) |