You are on page 1of 12

UNIVERSIDAD NACIONAL DE SAN AGUSTIN

FACULTAD DE PRODUCCION Y SERVICIOS

ESCUELA PROFESIONAL DE ING. INDUSTRIAL

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

Sub Ingresar4(ByRef n As Integer, ByRef np As Integer)


Console.Write("Ingresar nmero de postulantes: ")
n = Console.ReadLine
Console.Write("Ingrese # de preguntas: ")
np = Console.ReadLine
End Sub
Sub Leer_nombre(ByRef nomb() As String, ByVal n As Integer)
For x As Integer = 0 To (n - 1)
nomb(x) = Console.ReadLine
Next
End Sub
Sub Leer_cl(ByRef clave() As Integer, ByVal np As Integer)
Randomize()
Dim c As Integer
For c = 0 To (np - 1)
clave(c) = Rnd() * 4 + 1
Next
End Sub
Sub mostrar_clave(ByVal clave() As Integer, ByVal np As Integer)
Console.WriteLine("la clave de respuestas correctas es: ")
For cl As Integer = 0 To np - 1
Console.Write("{0}- {1}, ", cl + 1, clave(cl))
Next
End Sub
Sub Leer_matriz(ByRef resp(,) As Integer, ByVal n As Integer, ByVal np As
Integer)
Dim fil, col As Integer
Randomize()
For fil = 0 To n - 1
For col = 0 To np - 1
resp(fil, col) = Rnd() * 4 + 1
Next
Next
End Sub
Sub Proceso(ByVal resp(,) As Integer, ByVal clave() As Integer, ByVal n As
Integer, ByVal np As Integer, ByRef puntos() As Integer)
Dim s, f, c As Integer
For f = 0 To n - 1
s = 0
For c = 0 To np - 1
If (resp(f, c) = clave(c)) Then
s = s + 1
End If
Next
puntos(f) = s
Next
End Sub
Sub Mostrar_matriz(ByVal resp(,) As Integer, ByVal n As Integer, ByVal np As
Integer)
Console.WriteLine()
Console.WriteLine("Las repuestas de los estudiantes fueron")
Console.WriteLine()
For f As Integer = 0 To n - 1
For c As Integer = 0 To np - 1
Console.Write("{0}- {1} ,", c + 1, resp(f, c))
Next
Console.WriteLine()
Next
End Sub
Sub resultados(ByRef puntos() As Integer, ByVal np As Integer, ByVal n As
Integer)
Console.WriteLine()
For x As Integer = 0 To n - 1
Console.WriteLine("{0} alumno: {1} puntos de 100", x + 1, puntos(x) *
100 / np)
Next
End Sub
Sub menuexamen()
Console.Clear()
Dim n, np As Integer
Ingresar4(n, np)
Dim puntos(n) As Integer
Dim nomb(n) As String
Dim clave(np) As Integer
Dim resp(n, np) As Integer
Leer_nombre(nomb, n)
Leer_cl(clave, np)
mostrar_clave(clave, np)
Leer_matriz(resp, n, np)
Mostrar_matriz(resp, n, np)
Proceso(resp, clave, n, np, puntos)
resultados(puntos, np, n)
Console.ReadLine()
End Sub

Sub ingresa3(ByRef na As Integer, ByRef nc As Integer)


Console.Write("Ingrese la cantidad de alumnos: ")
na = Console.ReadLine
Console.Write("Ingrese el numero de cursos: ")
nc = Console.ReadLine
End Sub
Sub ingalumno(ByRef al() As String, ByVal n As Integer)
Dim x As Integer
For x = 0 To n - 1
Console.Write("Ingrese el nombre del alumno: ")
al(x) = Console.ReadLine
Next
End Sub
Sub ingcurso(ByRef cu() As String, ByVal n As Integer)
Dim x As Integer
For x = 0 To n - 1
Console.Write("Ingrese el nombre del curso: ")
cu(x) = Console.ReadLine
Next
End Sub
Sub notas(ByVal t(,) As Integer, ByVal na As Integer, ByVal nc As Integer)
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine()
For a As Integer = 0 To na - 1
Console.WriteLine()
Console.WriteLine()
For b As Integer = 0 To nc - 1
t(a, b) = Rnd() * 19 + 1
Console.Write("{0,20:F0}", t(a, b))
Next
Next
Console.WriteLine(" ")
End Sub
Sub mostraralumnos(ByVal al() As String, ByVal na As Integer)
Dim a As Integer = 5
For x As Integer = 0 To na - 1
Console.SetCursorPosition(2, x + a)
Console.WriteLine("{0}", al(x))
a = a + 1
Next
End Sub
Sub mostrarcursos(ByVal cu() As String, ByVal nc As Integer)
Dim i As Integer
Console.WriteLine()
For i = 0 To nc - 1
Console.Write("{0,22:D}", cu(i))
Next
End Sub
Sub promalum(ByVal t(,) As Integer, ByRef PA() As Integer, ByVal na As
Integer, ByVal nc As Integer)
For x As Integer = 0 To na - 1
Dim s As Integer = 0
For y As Integer = 0 To nc - 1
s = s + t(x, y)
Next
PA(x) = s / nc
Next
End Sub
Sub promcur(ByVal t(,) As Integer, ByRef Pc() As Integer, ByVal na As
Integer, ByVal nc As Integer)
For x As Integer = 0 To nc - 1
Dim s As Integer = 0
For y As Integer = 0 To na - 1
s = s + t(y, x)
Next
Pc(x) = s / na
Next
End Sub
Sub mostrarpa(ByVal PA() As Integer, ByVal na As Integer)
Dim a As Integer = 5
For x As Integer = 0 To na - 1
Console.SetCursorPosition(68, x + a)
Console.WriteLine("{0}", PA(x))
a = a + 1
Next
End Sub
Sub mostrarpc(ByVal Pc() As Integer, ByVal nc As Integer)
Dim i As Integer
Console.WriteLine()
Console.WriteLine()
For i = 0 To nc - 1
Console.Write("{0,20:D}", Pc(i))
Next
End Sub
Sub RANKING(ByVal al() As String, ByVal PA() As Integer, ByVal na As Integer)
Dim T, j, i As Integer
Dim TE As String
For i = 0 To na - 2
For j = i + 1 To na - 1
If PA(i) < PA(j) Then
T = PA(i)
PA(i) = PA(j)
PA(j) = T
TE = al(i)
al(i) = al(j)
al(j) = TE
End If
Next
Next
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(5, 20)
Console.WriteLine("RANKING DE NOTAS")
j = 22
For i = 0 To na - 1
Console.SetCursorPosition(3, i + j)
Console.WriteLine("NOMBRE: {0}", al(i))
Console.SetCursorPosition(3, i + j + 1)
Console.WriteLine("PROMEDIO: {0}", PA(i))
j = j + 1
Next
Console.WriteLine()
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine("El primer puesto es de: ")
Console.WriteLine("NOMBRE: {0}", al(0))
Console.WriteLine("PROMEDIO: {0}", pa(0))
End Sub
Sub marco()
Dim x As Integer
Console.ForegroundColor = ConsoleColor.White
Console.SetCursorPosition(0, 2)
Console.WriteLine("NOMBRE")
Console.SetCursorPosition(66, 2)
Console.WriteLine("PROM. ALUMNO")
Console.SetCursorPosition(0, 16)
Console.WriteLine("PROM. CURSO")
For x = 2 To 18
Console.SetCursorPosition(65, x)
Console.WriteLine("|")
Console.SetCursorPosition(15, x)
Console.WriteLine("|")
Next
For x = 0 To 77
Console.SetCursorPosition(x, 3)
Console.WriteLine("-")
Console.SetCursorPosition(x, 15)
Console.WriteLine("-")
Next
End Sub
Sub matrixnotas()
Console.Clear()
Dim na, nc As Integer
ingresa3(na, nc)
Dim al(na), cu(nc) As String
Dim T(na, nc), PA(na), PC(nc) As Integer
ingalumno(al, na)
ingcurso(cu, nc)
Console.Clear()
Console.WriteLine(" ")
mostrarcursos(cu, nc)
notas(T, na, nc)
mostraralumnos(al, na)
promalum(T, PA, na, nc)
mostrarpa(PA, na)
promcur(T, PC, na, nc)
mostrarpc(PC, nc)
marco()
RANKING(al, PA, na)
Console.ReadLine()
End Sub

Sub ingresar2(ByRef m As Integer)


Console.Write("Ingresar la cantidad de elementos en la pila:")
m = Console.ReadLine
End Sub

Sub Crearpila(ByRef Pila() As String, ByRef m As Single)


Dim x As Integer
For x = 0 To m - 1
Console.Write("Ingresar elemento: ")
Pila(x) = Console.ReadLine()
Next
End Sub
Sub Mostrarpila(ByVal Pila() As String, ByRef m As Single)
Dim x As Integer
For x = m - 1 To 0 Step -1
Console.WriteLine(" {0} - {1} ", x + 1, Pila(x))
Next
End Sub
Sub Ingresar2(ByVal Pila() As String, ByRef m As Single)
m = m + 1
Console.WriteLine("Ingresar elemento: ")
Pila(m - 1) = Console.ReadLine()
For x = m - 1 To 0 Step -1
Console.WriteLine(" {0} - {1} ", x + 1, Pila(x))
Next

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

Sub ingresar1(ByRef m As Integer)


Console.Write("Ingresar la cantidad de personas en la cola:")
m = Console.ReadLine
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

Sub menuprincipal(ByRef opc As Integer)


For x As Integer = 6 To 30
For y As Integer = 3 To 14
Console.BackgroundColor = ConsoleColor.DarkMagenta
Console.SetCursorPosition(x, y)
Console.Write(" ")
Next
Next
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(12, 5)
Console.WriteLine("Trabajo Final")
Console.SetCursorPosition(8, 6)
Console.WriteLine("1 Colas")
Console.SetCursorPosition(8, 7)
Console.WriteLine("2 Pilas")
Console.SetCursorPosition(8, 8)
Console.WriteLine("3 Matrix notas")
Console.SetCursorPosition(8, 9)
Console.WriteLine("4 Examen")
Console.SetCursorPosition(8, 10)
Console.WriteLine("5 Tinka")
Console.SetCursorPosition(8, 11)
Console.WriteLine("6 Fin")
Console.SetCursorPosition(8, 12)
Console.WriteLine("Escoger Opcion: ")
opc = Console.ReadLine
End Sub
Sub Main()
Do
Dim opc As Integer
menuprincipal(opc)
Select Case opc
Case 1
menucolas()
Case 2
menupilas()
Case 3
matrixnotas()
Case 4
menuexamen()
Case 5
tinka()
Case 6
End
End Select
Loop
End Sub

End Module

MENU.docx MENU DE COLAS Y


PILAS Y NOMBRES.docx

You might also like