You are on page 1of 12

Module module1

Sub main()
Dim n As Integer
desarrollo(n)

End Sub
Function menu(ByRef op As Integer)
Console.SetCursorPosition(35, 2)
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("MENU PRINCIPAL")
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(32, 4)
Console.WriteLine("1. COLAS ")
Console.SetCursorPosition(32, 5)
Console.WriteLine("2. PILAS ")
Console.SetCursorPosition(32, 6)
Console.WriteLine("3. CLASE ")
Console.SetCursorPosition(32, 7)
Console.WriteLine("4. EXAMEN DE INGRESO")
Console.SetCursorPosition(32, 8)
Console.WriteLine("5. TINKA ")
Console.SetCursorPosition(32, 9)
Console.WriteLine("6. NO SE REPITE ")
Console.SetCursorPosition(32, 10)
Console.WriteLine("7. FIN DEL PROGRAMA")
Console.SetCursorPosition(32, 12)
Console.Write("ESCOGER UNA OPCION: ")
op = Console.ReadLine
End Function

Sub ingresa_jugadas(ByRef n As Integer)


Console.Write("Ingrese el numero de jugadas: ")
n = Console.ReadLine
End Sub

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 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 + 40)
Console.WriteLine("{0}", A(Z))
Next
End Sub
Sub texto_tinka()
Dim x As Integer
Console.ForegroundColor = ConsoleColor.White
Console.BackgroundColor = ConsoleColor.Blue
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, 41)
Console.WriteLine("GANADORES CON 1 ACIERTO: ")
Console.SetCursorPosition(3, 42)
Console.WriteLine("GANADORES CON 2 ACIERTOS: ")
Console.SetCursorPosition(3, 43)
Console.WriteLine("GANADORES CON 3 ACIERTOS: ")
Console.SetCursorPosition(3, 44)
Console.WriteLine("GANADORES CON 4 ACIERTOS: ")
Console.SetCursorPosition(3, 45)
Console.WriteLine("GANADORES CON 5 ACIERTOS: ")
Console.SetCursorPosition(3, 46)
Console.WriteLine("GANADORES CON 6 ACIERTOS: ")
For x = 2 To 38
Console.SetCursorPosition(6, x)
Console.WriteLine("|")
Console.SetCursorPosition(65, x)
Console.WriteLine("|")
Next
For x = 0 To 77
Console.SetCursorPosition(x, 3)
Console.WriteLine("-")
Console.SetCursorPosition(x, 36)
Console.WriteLine("-")
Next
Console.BackgroundColor = ConsoleColor.Black
End Sub
Sub ingresa(ByRef na As Integer, ByRef nc As Integer)
Console.Write("Imgrese el numero de alumnos: ")
na = Console.ReadLine
Console.Write("Ingrese el numero de cursos: ")
nc = Console.ReadLine
End Sub

Sub nombre(ByRef v() As String, ByVal n As Integer)


Dim x As Integer
For x = 0 To n - 1
Console.Write("Ingrese el nombre del alumno: ")
v(x) = Console.ReadLine
Next
End Sub

Sub curso(ByRef v() As String, ByVal n As Integer)


Dim x As Integer
For x = 0 To n - 1
Console.Write("Ingrese el nombre del curso: ")
v(x) = Console.ReadLine
Next
End Sub

Sub notas(ByVal t(,) As Integer, ByVal na As Integer, ByVal nc As Integer)


Dim a, b As Integer
Console.ForegroundColor = ConsoleColor.White
'Console.WriteLine(" ")
Console.WriteLine(" ")
For a = 0 To na - 1
Console.WriteLine(" ")
Console.WriteLine(" ")
For b = 0 To nc - 1
t(a, b) = Rnd() * 19 + 1
Console.Write("{0,14:F0}", t(a, b))
Next
Next
Console.WriteLine(" ")
End Sub

Sub mostrar_nombres(ByVal v() As String, ByVal c As Integer, ByVal n As Integer)


Dim x As Integer, a As Integer = 5
For x = 0 To n - 1
Console.SetCursorPosition(c, x + a)
Console.WriteLine("{0}", v(x))
a = a + 1
Next
End Sub

Sub mostrarCurso(ByVal a() As String, ByVal n As Integer)


Dim i As Integer
Console.WriteLine(" ")
For i = 0 To n - 1
Console.Write("{0,15:D}", a(i))
Next
End Sub
Sub promedio(ByVal m(,) As Integer, ByRef PA() As Integer, ByVal na As Integer,
ByVal nc As Integer)
Dim x, y, s As Integer
For x = 0 To na - 1
For y = 0 To nc - 1
s = s + m(x, y)
Next
PA(x) = s / nc
s = 0
Next
End Sub

Sub promedioc(ByVal m(,) As Integer, ByRef Pc() As Integer, ByVal na As Integer,


ByVal nc As Integer)
Dim x, y, s As Integer
For x = 0 To nc - 1
For y = 0 To na - 1
s = s + m(y, x)
Next
Pc(x) = s / na
s = 0
Next
End Sub

Sub mostrar(ByVal v() As Integer, ByVal c As Integer, ByVal n As Integer)


Dim x As Integer, a As Integer = 5
For x = 0 To n - 1
Console.SetCursorPosition(c, x + a)
Console.WriteLine("{0}", v(x))
a = a + 1
Next
End Sub

Sub mostrarc(ByVal a() As Integer, ByVal n As Integer)


Dim i As Integer
Console.WriteLine(" ")
Console.WriteLine(" ")
For i = 0 To n - 1
Console.Write("{0,15:D}", a(i))
Next
End Sub

Sub RANKING(ByVal AL() As String, ByVal pa() As Integer, ByVal Na As Integer)


Dim I, J, T 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.Magenta
Console.SetCursorPosition(30, 18)
Console.WriteLine("RANKING DE NOTAS")
J = 20
For I = 0 To Na - 1
Console.SetCursorPosition(30, I + J)
Console.WriteLine("NOMBRE: {0}", AL(I))
Console.SetCursorPosition(30, I + J + 1)
Console.WriteLine("PROMEDIO: {0}", pa(I))
J = J + 1
Next
Console.ForegroundColor = ConsoleColor.White
Console.BackgroundColor = ConsoleColor.DarkRed
Console.WriteLine("El primer puesto es de: ")
Console.WriteLine("NOMBRE: {0}", AL(0))
Console.WriteLine("PROMEDIO: {0}", pa(0))
Console.BackgroundColor = ConsoleColor.Black
End Sub

Sub texto_clase()
Dim x As Integer
Console.ForegroundColor = ConsoleColor.White
Console.BackgroundColor = ConsoleColor.Blue
Console.SetCursorPosition(0, 2)
Console.WriteLine("NOMBRE")
Console.SetCursorPosition(66, 2)
Console.WriteLine("PROMEDIOALUMNO")
Console.SetCursorPosition(0, 17)
Console.WriteLine("PROMEDIO")
Console.SetCursorPosition(0, 18)
Console.WriteLine("CURSO")
For x = 2 To 18
Console.SetCursorPosition(8, x)
Console.WriteLine("|")
Console.SetCursorPosition(65, 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 ingresa(ByRef NP As Integer)


Console.Write("Ingrese el numero de postulantes: ")
NP = Console.ReadLine
End Sub

Sub generar_codigos(ByVal V() As Integer, ByVal n As Integer)


Dim a, b, num As Integer
For a = 0 To n - 1
num = Rnd() * 50000 + 40000
If a > 0 Then
For b = 0 To n - 1
If num = V(b) Then
num = Rnd() * 50000 + 40000
b = -1
End If
Next
End If
V(a) = num
Next
End Sub

Sub GENERA_CLAVE(ByVal V() As Integer, ByVal n As Integer)


Dim a As Integer
For a = 0 To n - 1
V(a) = Rnd() * 4 + 1
Next
End Sub

Sub MOSTRAR_VECTOR(ByVal V() As Integer, ByVal N As Integer)


Dim X As Integer
Console.WriteLine(" ")
Console.WriteLine("CLAVE DE RESPUESTAS")
Console.WriteLine(" ")
For X = 0 To N - 1
Console.Write("{0,2:D}", V(X))
Next
End Sub

Sub comparar(ByVal CL() As Integer, ByVal T(,) As Integer, ByVal CO() As


Integer, ByVal nP As Integer, ByVal C() As Integer)
Dim x, y, z As Integer
Console.WriteLine(" ")
Console.WriteLine(" ")
Console.WriteLine("PUNTAJE")
Console.WriteLine(" ")
For x = 0 To nP - 1
For y = 0 To 5
If CL(y) = T(x, y) Then
z = z + 1
End If
Next
CO(x) = z
Console.WriteLine("EL POSTULANTE DE CODIGO {0} TUVO {1} PUNTOS", C(x),
CO(x))
z = 0
Next
End Sub

Sub RANKING(ByVal C() As Integer, ByVal CO() As Integer, ByVal NP As Integer)


Dim I, J, T As Integer
Dim TE As String
For I = 0 To NP - 2
For J = I + 1 To NP - 1
If CO(I) < CO(J) Then
T = CO(I)
CO(I) = CO(J)
CO(J) = T
TE = C(I)
C(I) = C(J)
C(J) = TE
End If
Next
Next
Console.SetCursorPosition(50, 58)
Console.WriteLine("RANKING DE PUNTAJES")
J = 60
For I = 0 To NP - 1
Console.SetCursorPosition(50, I + J)
Console.WriteLine("CODIGO: {0}", C(I))
Console.SetCursorPosition(50, I + J + 1)
Console.WriteLine("PUNTAJE: {0}", CO(I))
J = J + 1
Next
Console.BackgroundColor = ConsoleColor.Black
End Sub

Sub RESPUESTAS(ByVal T(,) As Integer, ByVal na As Integer, ByVal nc As Integer,


ByVal C() As Integer)
Dim a, b As Integer

For a = 0 To na - 1
Console.BackgroundColor = ConsoleColor.Blue
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("")
Console.WriteLine("")
Console.WriteLine("POSTULANTE N {0} CODIGO: {1}", a + 1, C(a))
Console.WriteLine("")
For b = 0 To nc - 1
T(a, b) = Rnd() * 4 + 1
Console.Write("{0,2:F0}", T(a, b))
Next
Next
Console.WriteLine(" ")

End Sub

Sub ingresa_aleatorios(ByRef n As Integer)


Console.Write("Ingrese la cantidad de aleatorios a generar: ")
n = Console.ReadLine
End Sub

Sub aleatorios(ByVal V() As Integer, ByVal n As Integer)


Randomize()
Dim X, Y, NUM As Integer
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("NUMEROS ALEATORIOS SIN REPETICION")
Console.WriteLine(" ")

For X = 0 To n
NUM = Rnd() * (n - 1) + 1
If X > 0 Then
For Y = 0 To n
If NUM = V(Y) Then
NUM = Rnd() * (n - 1) + 1
Y = -1
End If
Next
End If
V(X) = NUM
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine("V[{0}]={1}", X, V(X))
Next
End Sub

Sub desarrollo(ByVal op As Integer)


Do
Console.Clear()
menu(op)
Select Case (op)
Case 1
Console.Clear()
colas()
Case 2
Console.Clear()
pilas()
Case 3
Console.Clear()
Dim na, nc As Integer
ingresa(na, nc)
Dim AL(na), CN(nc) As String
Dim T(na, nc), PA(na), PC(nc) As Integer
nombre(AL, na)
curso(CN, nc)
Console.Clear()
Console.WriteLine(" ")
mostrarCurso(CN, nc)
notas(T, na, nc)
texto_clase()
mostrar_nombres(AL, 2, na)
promedio(T, PA, na, nc)
mostrar(PA, 68, na)
promedioc(T, PC, na, nc)
mostrarc(PC, nc)
RANKING(AL, PA, na)
Console.ReadLine()

Case 4
Console.Clear()
Dim NP As Integer
ingresa(NP)
Dim C(NP), R(NP, 60), CL(60), CO(NP) As Integer
generar_codigos(C, NP)
RESPUESTAS(R, NP, 60, C)
GENERA_CLAVE(CL, 60)
MOSTRAR_VECTOR(CL, 60)
comparar(CL, R, CO, NP, C)
RANKING(C, CO, NP)
Console.ReadLine()

Case 5
Console.Clear()
Dim n As Integer
ingresa_jugadas(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_tinka()
FRECUENCIA(c, A, n)
Console.ReadLine()
Case 6
Console.Clear()
Dim n As Integer
ingresa_aleatorios(n)
Dim v(n) As Integer
aleatorios(v, n)

Case 7
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(24, 10)
Console.WriteLine("<< Programa Finalizado >>")
System.Threading.Thread.Sleep(2000)
End Select
Loop While (op < 7)
End Sub
Function colas()
Const max As Integer = 30
Dim cola(max), ne, op, i As Integer
ne = 0
Do
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine()
Console.WriteLine(" MENU DE COLAS ")
Console.WriteLine("")
Console.ForegroundColor = ConsoleColor.Cyan
Console.WriteLine(" 1. INGRESAR DATOS ")
Console.WriteLine(" 2. SACAR ELEMENTOS DE LA COLA ")
Console.WriteLine(" 3. LISTAR DATOS ")
Console.WriteLine(" 4. SALIR ")
Console.Write(" INGRESE OPCION ==> ")
op = Console.ReadLine()
Console.ForegroundColor = ConsoleColor.Blue
Select Case op
Case 1 : For i = ne To 1 Step -1
cola(i) = cola(i - 1)
Next
Console.Write(" Ingrese Elemento {0} a la Cola: ", ne)
cola(0) = Console.ReadLine()
ne += 1
Case 2 : If (ne > 0) Then
ne -= 1
Console.WriteLine("SALE EL ELEMENTO {0} DE LA COLA",
cola(ne))
Else : Console.WriteLine(" COLA VACIA ")
End If
Case 3 : If (ne >= 0) Then
Console.WriteLine(" ELEMENTOS EN LA COLA ")
For i = 0 To ne - 1
Console.Write("{0,5:d}", cola(i))
Next
Else
Console.WriteLine("COLA VACIA ")
End If
Case Else
Console.WriteLine("PROGRAMA FINALIZADO")
End Select
Loop While (op <> 4)
' Console.ReadLine()
End Function

Function pilas()
Const max As Integer = 30
Dim pila(max), ne, op, i As Integer
ne = 0
Do
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine()
Console.WriteLine(" MENU DE PILA ")
Console.WriteLine(" 1. INGRESAR DATOS")
Console.WriteLine(" 2. SACAR LOS ELEMENTOS DE LA PILA ")
Console.WriteLine(" 3. LISTAR DATOS ")
Console.WriteLine(" 4. SALIR ")
Console.Write(" INGRESE OPCION =======> ")
op = Console.ReadLine()
Console.ForegroundColor = ConsoleColor.White
Select Case op
Case 1 : For i = ne To 1 Step -1
pila(i) = pila(i - 1)
Next
Console.Write(" INGRESE EL ELEMENTO {0} A LA PILA: ", ne)
pila(0) = Console.ReadLine()
ne += 1

Case 2 : If (ne > 0) Then


Console.WriteLine("SALE EL ELEMENTO {0} DE LA PILA ",
pila(0))
For i = 0 To ne - 1
pila(i) = pila(i + 1)
Next
ne -= 1
Else : Console.WriteLine(" PILA VACIA ")
End If
Case 3 : If (ne > 0) Then
Console.WriteLine(" ELEMENTOS EN LA PILA ")
For i = 0 To ne - 1
Console.Write("{0,5:d}", pila(i))
Next
Else
Console.WriteLine("PILA VACIA ")
End If
Case Else
Console.WriteLine("<< PROGRAMA FINALIZADO >>")
End Select
Loop While (op <> 4)
Console.ReadLine()
End Function
End Module

You might also like