Professional Documents
Culture Documents
Trabajo Final
Trabajo Final
TRABAJO FINAL
Curso:
Programacin y mtodos numricos.
Docente:
Juan Carlos Torreblanca
Nombre del grupo:
Larry Page & Sergey Brin
INTEGRANTES:
Leonello Frank Romero Calla
Cesar Augusto V Arios Castro
Rusmael Lagos Peralta
Vctor Hugo Arenas Meneses
Hilary Villena Ojeda
Arequipa 2017
Module Module1
Sub generar(ByVal V() As Integer, ByVal n As Integer)
Dim a, b, num As Integer
For a = 0 To n - 1
num = Rnd() * 49 + 1
If a > 0 Then
For b = 0 To n - 1
If num = V(b) Then
num = Rnd() * 49 + 1
b = -1
End If
Next
End If
V(a) = num
Next
End Sub
Sub jugada(ByVal j(,) As Integer, ByVal n As Integer)
Dim a, b, c, num As Integer
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine(" ")
Console.WriteLine(" ")
Console.WriteLine(" ")
For a = 0 To n - 1
Console.WriteLine(" ")
For b = 0 To 5
num = Rnd() * 45 + 1
If b > 0 Then
For c = 0 To 5
If num = j(a, c) Then
num = Rnd() * 45 + 1
c = -1
End If
Next
End If
j(a, b) = num
Console.Write("{0,10:F0}", j(a, b))
Next
Next
Console.WriteLine(" ")
End Sub
Sub comparar(ByVal jg() As Integer, ByVal j(,) As Integer, ByVal n As
Integer, ByVal c() As Integer)
Dim x, y, z As Integer
For x = 0 To n - 1
For y = 0 To 5
If jg(y) = j(x, y) Then
z = z + 1
End If
Next
c(x) = z
z = 0
Next
End Sub
Sub ingresa(ByRef n As Integer)
Console.Write("Ingrese el numero de jugadas: ")
n = Console.ReadLine
End Sub
Sub mostrarv(ByVal c() As Integer, ByVal n As Integer, ByVal a As Integer)
Dim x As Integer
Console.WriteLine(" ")
Console.ForegroundColor = ConsoleColor.Green
For x = 0 To n - 1
Console.SetCursorPosition(a, x + 4)
Console.WriteLine("{0}", c(x))
Next
End Sub
Sub mostrar(ByVal a() As Integer, ByVal n As Integer)
Dim i As Integer
Console.ForegroundColor = ConsoleColor.White
Console.BackgroundColor = ConsoleColor.DarkRed
Console.WriteLine()
Console.WriteLine(" JUGADA GANADORA
")
For i = 0 To n - 1
Console.BackgroundColor = ConsoleColor.Black
Console.Write("{0,10:D}", a(i))
Next
End Sub
Sub FRECUENCIA(ByVal C() As Integer, ByVal A() As Integer, ByVal N As
Integer)
Dim X, Z, CO As Integer
For Z = 1 To 6
For X = 0 To N - 1
If C(X) = Z Then
CO = CO + 1
End If
A(Z) = CO
Next
CO = 0
Console.SetCursorPosition(30, Z + 20)
Console.WriteLine("{0}", A(Z))
Next
End Sub
Sub texto(ByRef n As Integer)
Dim x As Integer
Console.ForegroundColor = ConsoleColor.White
Console.SetCursorPosition(30, 0)
Console.WriteLine(" TINKA")
Console.SetCursorPosition(30, 1)
Console.WriteLine(" =====")
Console.SetCursorPosition(0, 2)
Console.WriteLine("CODIGO")
Console.SetCursorPosition(30, 2)
Console.WriteLine(" JUGADAS")
Console.SetCursorPosition(67, 2)
Console.WriteLine("ACIERTOS")
Console.SetCursorPosition(3, 21)
Console.WriteLine("GANADORES CON 1 ACIERTO: ")
Console.SetCursorPosition(3, 22)
Console.WriteLine("GANADORES CON 2 ACIERTOS: ")
Console.SetCursorPosition(3, 23)
Console.WriteLine("GANADORES CON 3 ACIERTOS: ")
Console.SetCursorPosition(3, 24)
Console.WriteLine("GANADORES CON 4 ACIERTOS: ")
Console.SetCursorPosition(3, 25)
Console.WriteLine("GANADORES CON 5 ACIERTOS: ")
Console.SetCursorPosition(3, 26)
Console.WriteLine("GANADORES CON 6 ACIERTOS: ")
For y As Integer = 2 To (n + 6)
Console.SetCursorPosition(6, y)
Console.WriteLine("|")
Console.SetCursorPosition(65, y)
Console.WriteLine("|")
Next
For x = 0 To 77
Console.SetCursorPosition(x, 3)
Console.WriteLine("-")
Next
End Sub
Sub tinka()
Console.Clear()
Dim n As Integer
ingresa(n)
Console.Clear()
Dim v(n), j(n, 6), jg(6), c(n), A(6) As Integer
generar(v, n)
jugada(j, n)
generar(jg, 6)
comparar(jg, j, n, c)
mostrarv(v, n, 2)
mostrarv(c, n, 70)
mostrar(jg, 6)
texto(n)
FRECUENCIA(c, A, n)
Console.ReadLine()
End Sub
End Sub
Function Menu2()
Console.Clear()
Dim op As Integer
Console.WriteLine(" MENU DE PILAS ")
Console.WriteLine(" 1. Crear pila")
Console.WriteLine(" 2. Mostrar pila")
Console.WriteLine(" 3. Ingresar a pila")
Console.WriteLine(" 4. Fin ")
Console.Write(" Escoger una opcion: ")
op = Console.ReadLine()
Return op
End Function
Sub menupilas()
Console.Clear()
Dim m As Integer
ingresar2(m)
Dim Pila(m) As String
Dim opcion As Integer
Do
opcion = Menu2()
Console.Clear()
Select Case opcion
Case 1
Crearpila(Pila, m)
Case 2
Mostrarpila(Pila, m)
Case 3
ingresar2(Pila, m)
Case 4
End Select
Console.ReadLine()
Loop While (opcion < 4)
Console.Clear()
End Sub
Function menu1()
Console.Clear()
Dim op As Integer
Console.SetCursorPosition(25, 4)
Console.WriteLine("COLAS")
Console.SetCursorPosition(30, 5)
Console.WriteLine(" 1.Crear cola ")
Console.SetCursorPosition(30, 6)
Console.WriteLine(" 2.Mostrar cola ")
Console.SetCursorPosition(30, 7)
Console.WriteLine(" 3.Ingresar a la cola ")
Console.SetCursorPosition(30, 8)
Console.WriteLine(" 4.Fin ")
Console.SetCursorPosition(30, 9)
Console.Write(" Escoger una opcin: ")
op = Console.ReadLine()
Return op
End Function
Sub Crearcola(ByRef nombre() As String, ByRef m As Single)
Dim x As Integer
For x = 0 To m - 1
Console.Write(" Ingresar nombre: ")
nombre(x) = Console.ReadLine()
Next
End Sub
Sub Mostrarcola(ByVal nombre() As String, ByVal m As Single)
Dim x As Integer
For x = 0 To m - 1
Console.WriteLine(" {0} - {1} ", x + 1, nombre(x))
Next
End Sub
Sub Ingresar1(ByVal nombre() As String, ByRef m As Single)
m = m + 1
Console.Write(" Ingresar nombre: ")
nombre(m - 1) = Console.ReadLine()
Mostrarcola(nombre, m)
End Sub
Sub menucolas()
Console.Clear()
Dim m As Integer
ingresar1(m)
Dim nombre(m) As String
Dim opcion As Integer
Do
opcion = menu1()
Console.Clear()
Select Case opcion
Case 1
Crearcola(nombre, m)
Case 2
Mostrarcola(nombre, m)
Case 3
ingresar1(nombre, m)
Case 4
End Select
Console.ReadLine()
Loop While (opcion < 4)
End Sub
End Module