0% found this document useful (0 votes)
50 views9 pages

Ejercicios Programación 1.-Menú de Opciones: Sub Dim As Integer

The document contains code for 6 programming exercises: 1) A menu with options for different graphics programs 2) A Tower of Hanoi graphic 3) A tennis court graphic that changes colors 4) A chessboard graphic that toggles black and white squares 5) A hangman graphic 6) A multiplication table printout
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views9 pages

Ejercicios Programación 1.-Menú de Opciones: Sub Dim As Integer

The document contains code for 6 programming exercises: 1) A menu with options for different graphics programs 2) A Tower of Hanoi graphic 3) A tennis court graphic that changes colors 4) A chessboard graphic that toggles black and white squares 5) A hangman graphic 6) A multiplication table printout
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

EJERCICIOS PROGRAMACIÓN

1.-MENÚ DE OPCIONES

Module Module1
Sub Main()
Console.Title = "MENU DE OPCIONES"
Dim Opcion As Integer = 0
Console.SetCursorPosition(20, 1)
Console.WriteLine("Graficos")
Console.SetCursorPosition(1, 2)
Console.WriteLine("")
Console.SetCursorPosition(1, 3)
Console.WriteLine("1.- Torre de Hanoi")
Console.SetCursorPosition(1, 4)
Console.WriteLine("2.- Cancha de Tenis")
Console.SetCursorPosition(1, 5)
Console.WriteLine("3.- Ajedrez")
Console.SetCursorPosition(1, 6)
Console.WriteLine("4.- Ahorcado")
Console.SetCursorPosition(1, 7)
Console.WriteLine("5.- Tabla de Multiplicar")
Console.SetCursorPosition(1, 8)
Console.WriteLine("")
Console.SetCursorPosition(1, 9)
Console.Write("Teclee la Opcion Deseada: ")

Select Case Opcion


Case 1

Case 2

Case 3

Case 4

Case 5

End Select
Opcion = Console.ReadLine()
End Sub
End Module
2.-TORRE DE HANOI

Module Module1
Dim Pisos As Integer
Dim AnchoPrimerPiso As Integer = 3
Sub Main()
Console.Write("Ingrese el número de pisos para la torre de Hanoi: ")
Pisos = Console.ReadLine
Console.Clear()
For Y As Integer = 0 To (Pisos - 1)
Console.BackgroundColor = AsignarColor(Y + 1)
For X As Integer = Inicio_X(Y) To Final_X(Y)
Console.SetCursorPosition(X, Y)
Console.Write(" ")
Next
Next
Console.ReadLine()
End Sub
Function Inicio_X(ByVal Y As Integer) As Integer
Dim X As Integer
X = Pisos - 1 - Y
Return X
End Function
Function Final_X(ByVal Y As Integer) As Integer
Dim X As Integer
X = Inicio_X(Y) + AnchoPrimerPiso + 2 * Y - 1
Return X
End Function
Function AsignarColor(ByVal C As Integer) As Integer
While (C > 15)
C -= 15
End While
Return C
End Function
End Module
3.-CANCHA DE TENNIS

Module Module1

Sub Main()
Dim col As Integer
Dim fil As Integer
Dim a As Integer
Console.SetCursorPosition(1, 26)
Console.WriteLine("Presione enter para cambiar de colores a la cancha")
For a = 2 To 15

Console.BackgroundColor = a
Console.WriteLine()

For col = 1 To 80 Step 1

Console.SetCursorPosition(col, 0)
Console.Write(" ")
Console.SetCursorPosition(col, 4)
Console.Write(" ")
Console.SetCursorPosition(col, 24)
Console.Write(" ")

Next

For col = 1 To 80 Step 1

Console.SetCursorPosition(col, 20)
Console.Write(" ")

Next

For col = 10 To 70 Step 1

Console.SetCursorPosition(col, 12)
Console.Write(" ")

Next
For fil = 1 To 24 Step 1

Console.SetCursorPosition(0, fil)
Console.Write(" ")
Console.SetCursorPosition(80, fil)
Console.Write(" ")
Console.SetCursorPosition(40, fil)
Console.Write(" ")

Next

For fil = 5 To 20 Step 1

Console.SetCursorPosition(10, fil)
Console.Write(" ")

Console.SetCursorPosition(70, fil)
Console.Write(" ")
Next

Console.ReadLine()
Next

End Sub

End Module
4.-AJEDREZ

Module Module1
Dim FondoEsNegro As Boolean = False
Sub Main()
Dim Ancho, Altura As Integer

Console.WriteLine("Ingresar ancho de cuadrícula")


Ancho = Math.Round(Conversion.Val(Console.ReadLine()))
Console.WriteLine("Ingresar altura de cuadrícula")
Altura = Math.Round(Conversion.Val(Console.ReadLine()))

Console.Clear()

For Y As Integer = 1 To Altura

For X As Integer = 1 To Ancho

Dim Cuadro As String


Cuadro = " "
CambiarColor()
Console.Write(Cuadro)

Threading.Thread.Sleep(10)

Next

If (Ancho Mod 2) = 0 Then


CambiarColor()
End If

Console.WriteLine()

Next

Console.ReadLine()

End Sub

Public Sub CambiarColor()


If FondoEsNegro Then
Console.BackgroundColor = ConsoleColor.White
FondoEsNegro = False
Else
Console.BackgroundColor = ConsoleColor.Black
FondoEsNegro = True
End If
End Sub

End Module
5.-AHORCADO

Module Module1

Sub Main()
Dim col, fil As Integer
Console.BackgroundColor = ConsoleColor.Green
For col = 0 To 79
For fil = 0 To 25
Console.SetCursorPosition(col, fil)
Console.Write(" ")
Next
Next
Console.BackgroundColor = ConsoleColor.White

col = 5
While (col <= 40)
Console.SetCursorPosition(col, 1)
col = col + 1
Console.Write(" ")
End While
col = 36
While (col <= 44)
Console.SetCursorPosition(col, 4)
col = col + 1
Console.Write(" ")
End While
col = 36
While (col <= 44)
Console.SetCursorPosition(col, 8)
col = col + 1
Console.Write(" ")
End While
fil = 4
While (fil <= 8)
Console.SetCursorPosition(36, fil)
fil = fil + 1
Console.Write(" ")
End While

fil = 4
While (fil <= 8)
Console.SetCursorPosition(44, fil)
fil = fil + 1
Console.Write(" ")
End While

fil = 1
While (fil <= 23)
Console.SetCursorPosition(5, fil)
fil = fil + 1
Console.Write(" ")
End While

fil = 1
While (fil <= 4)
Console.SetCursorPosition(40, fil)
fil = fil + 1
Console.Write(" ")
End While
fil = 8
While (fil <= 16)
Console.SetCursorPosition(40, fil)
fil = fil + 1
Console.Write(" ")
End While

col = 36
While (col <= 44)
Console.SetCursorPosition(col, 12)
col = col + 1
Console.Write(" ")
End While

col = 36
While (col <= 44)
Console.SetCursorPosition(col, 16)
col = col + 1
Console.Write(" ")
End While

Console.ReadLine()
End Sub

End Module
6.-TABLA DE MULTIPLICAR

Module Module1

Sub Main()
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t As Integer
Console.SetCursorPosition(20, 1)
Console.Write("TABLA DE MULTIPLICAR")

For a = 1 To 10
For b = 1 To 1
Console.SetCursorPosition(0, a + 2)
Console.WriteLine("{0}*{1}= {2}", a, b, a * b)

Next b
Next a

For c = 1 To 10
For d = 2 To 2
Console.SetCursorPosition(12, c + 2)
Console.WriteLine("{0}*{1}= {2}", c, d, c * d)

Next d
Next c
For e = 1 To 10
For f = 3 To 3
Console.SetCursorPosition(24, e + 2)
Console.WriteLine("{0}*{1}= {2}", e, f, e * f)

Next f
Next e
For g = 1 To 10
For h = 4 To 4
Console.SetCursorPosition(36, g + 2)
Console.WriteLine("{0}*{1}= {2}", g, h, g * h)

Next h
Next g
For i = 1 To 10
For j = 5 To 5
Console.SetCursorPosition(48, i + 2)
Console.WriteLine("{0}*{1}= {2}", i, j, i * j)

Next j
Next i
For k = 1 To 10
For l = 6 To 6
Console.SetCursorPosition(0, k + 14)
Console.WriteLine("{0}*{1}= {2}", k, l, k * l)
Next l
Next k

For m = 1 To 10
n = 7
Console.SetCursorPosition(12, m + 14)
Console.WriteLine("{0}*{1}= {2}", m, n, m * n)
Next
For o = 1 To 10
p = 8
Console.SetCursorPosition(24, o + 14)
Console.WriteLine("{0}*{1}= {2}", o, p, o * p)
Next
For q = 1 To 10
r = 9
Console.SetCursorPosition(36, q + 14)
Console.WriteLine("{0}*{1}= {2}", q, r, q * r)
Next
For s = 1 To 10
t = 10
Console.SetCursorPosition(48, s + 14)
Console.WriteLine("{0}*{1}= {2}", s, t, s * t)
Next

Console.ReadLine()

End Sub

End Module

You might also like