0% found this document useful (0 votes)
16 views10 pages

Programación 12

The document discusses a program for an admission exam with 60 questions. It includes functions to input the number of students, generate random student codes and scores for each student on each question, and output the scores.
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)
16 views10 pages

Programación 12

The document discusses a program for an admission exam with 60 questions. It includes functions to input the number of students, generate random student codes and scores for each student on each question, and output the scores.
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/ 10

UNIVERSIDAD NACIONAL DE SAN AGUSTN

FACULTAD DE PRODUCCIN Y SERVICIOS

ESCUELA PROFESIONAL DE INGENIERA INDUSTRIAL

CURSO

: PROGRAMACIN Y MTODOS NUMRICOS

DOCENTE

: Juan Carlos Torreblanca

GRUPO COOPER:
* Chvez Mendoza, Sheyla
* Guzmn Coaguila, Diana
* Pulcha Montenegro, Vanessa

1-PARA HALLA LA SUMA D ELA DIAGONAL


PRINCIPAL
Module Module1
Sub leer_matriz(ByRef m(,) As Integer, ByVal f As Integer, ByVal c As Integer)
Dim x, y As Integer
Console.Write("PROGRAMA PARA HALLAR LA DIAGONAL ")
Console.WriteLine(" ")
For x = 1 To f
For y = 1 To c
Console.Write("Ingresar el elmento m[{0},{1}]=", x, y)
m(x, y) = Console.ReadLine()
Next
Next
End Sub
Sub MOSTRAR_MATRIZ(ByVal m(,) As Integer, ByVal f As Integer, ByVal c As Integer)
Dim x, y As Integer
Console.Write("PROGRAMA PARA HALLAR LA DIAGONAL ")
Console.WriteLine(" ")
For x = 1 To f
For y = 1 To c
Console.SetCursorPosition(y, x)
Console.Write("{0}", m(x, y))
Next
Next
End Sub
Function diagonal(ByVal m(,) As Integer, ByVal f As Integer, ByVal c As Integer) As Integer
Dim sd As Integer
For x = 1 To f
For y = 1 To c
Console.SetCursorPosition(y, x)
Console.Write("{0}", m(x, y))
If (x = y) Then
sd = sd + m(x, y)
End If
Next
Next
Return sd
End Function
Sub main()
Dim f As Integer = 3
Dim C As Integer = 3
Dim sd As Integer
Dim m(f, C) As Integer
leer_matriz(m, f, C)
Console.Clear()
MOSTRAR_MATRIZ(m, f, C)
Console.Write(" ")
Console.Write("la diagonal es {0} ", diagonal(m, f, C))
Console.ReadLine()
End Sub
End Module

2-INGRESAR NOMBRES DE ALUMNOS, CURSOS Y


NOTAS POR CADA CURSO:
Module Module1
Sub num(ByRef nalum As String, ByRef ncur As Single)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine(" PROGRAMA DE N ALUMNOS Y N CURSOS CON SUS NOTAS Y RANKING ")
Console.WriteLine("*******************************************************************")
Console.ForegroundColor = ConsoleColor.Cyan
Console.Write(" INGRESAR NRO DE ALUMNOS = ")
Console.ForegroundColor = ConsoleColor.Yellow
nalum = Console.ReadLine()
Console.ForegroundColor = ConsoleColor.Cyan
Console.Write(" INGRESAR NRO DE CURSOS = ")
Console.ForegroundColor = ConsoleColor.Yellow
ncur = Console.ReadLine()
Console.Clear()
End Sub
Sub leernombres(ByRef nomalum() As String, ByVal nalum As Single)
For x = 0 To nalum - 1
Console.Write(" EL NOMBRE DEL ALUMNO {0}= ", x + 1)
nomalum(x) = Console.ReadLine()
Next
End Sub
Sub mostrarnombres(ByVal nomalum() As String, ByVal nalum As Single)
For x = 0 To nalum - 1
Console.SetCursorPosition(10, 3 + x)
Console.WriteLine(" {0} ", nomalum(x))
Next
End Sub
Sub leercursos(ByVal nomcur() As String, ByVal ncur As Single)
Console.ForegroundColor = ConsoleColor.Green
For x = 0 To ncur - 1
Console.Write(" NOMBRE DEL CURSO {0}= ", x + 1)
nomcur(x) = Console.ReadLine()
Next
Console.Clear()
End Sub
Sub mostrarcursos(ByVal nomcur() As String, ByVal ncur As Single)

For x = 0 To ncur - 1
Console.SetCursorPosition(18 + x * 8, 2)
Console.Write(" {0} ", nomcur(x))
Next
End Sub
Sub pro_alu(ByVal notas(,) As Integer, ByVal nalum As Single, ByVal ncur As Single, ByVal pral() As Single)
Dim sumanota As Integer = 0
For n = 0 To nalum - 1
For z = 0 To ncur - 1
sumanota = sumanota + notas(z, n)
Next
pral(n) = sumanota / nalum
Console.SetCursorPosition(18 + 8 * ncur, 3 + n)
Console.Write(" {0} ", pral(n))
sumanota = 0
Next
End Sub
Sub pro_cur(ByVal notas(,) As Integer, ByVal nalum As Single, ByVal ncur As Single, ByRef prcu() As Single)
Dim sumanota As Integer = 0
For z = 0 To nalum - 1
For n = 0 To ncur - 1
sumanota = sumanota + notas(z, n)
Next
prcu(z) = sumanota / nalum
Console.SetCursorPosition(18 + 8 * z, 3 + nalum)
Console.Write(" {0} ", prcu(z))
sumanota = 0
Next
End Sub
Sub RANKING(ByVal nomalum() As String, ByVal pral() As Single, ByVal nalum As Single)
Dim I, J, T As Integer
Dim TE As String
For I = 0 To nalum - 2
For J = I + 1 To nalum - 1
If pral(I) < pral(J) Then
T = pral(I)
pral(I) = pral(J)
pral(J) = T
TE = nomalum(I)
nomalum(I) = nomalum(J)
nomalum(J) = TE
End If
Next
Next
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(10, 10)
Console.WriteLine("RANKING DE NOTAS")
Console.WriteLine("************************************")
Console.SetCursorPosition(3, 12)
Console.WriteLine("PUESTO NOMBRES
NOTAS ")
For I = 0 To nalum - 1
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(5, I + 14)
Console.WriteLine("{0}
{1}", I + 1, nomalum(I))
Console.SetCursorPosition(29, I + 14)
Console.WriteLine("{0}", pral(I))
J=J+1
Next
End Sub
Sub proalumnos(ByVal pral() As Single, ByVal nalum As Single)
Dim suma As Single = 0
For x = 0 To nalum
suma = suma + pral(x)
Next
Console.WriteLine("
El promedio de todos los alumnos es {0}", suma / nalum)
End Sub
Sub procurso(ByVal prcu() As Single, ByVal ncur As Single)
Dim suma As Single = 0
For x = 0 To ncur

suma = suma + prcu(x)


Next
Console.WriteLine("
El promedio de todos los cursos es {0}", suma / ncur)
End Sub
Sub Main()
Dim nalum, ncur As Single
num(nalum, ncur)
Dim pral(nalum) As Single
Dim prcu(ncur) As Single
Dim nomalum(nalum) As String
Dim nomcur(ncur) As String
Dim notas(nalum, ncur) As Integer
leernombres(nomalum, nalum)
leercursos(nomcur, ncur)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine(" PROGRAMA DE N ALUMNOS Y N CURSOS CON SUS NOTAS Y RANKING ")
Console.WriteLine("*******************************************************************")
Console.ForegroundColor = ConsoleColor.Cyan
mostrarnombres(nomalum, nalum)
mostrarcursos(nomcur, ncur)
Console.ForegroundColor = ConsoleColor.Blue
For x = 0 To nalum - 1
For y = 0 To ncur - 1
notas(x, y) = Rnd() * 20 + 1
Next
Next
For x = 0 To nalum - 1
For y = 0 To ncur - 1
Console.SetCursorPosition(18 + x * 8, 3 + y)
Console.Write(" {0} ", notas(x, y))
Next
Next
pro_alu(notas, nalum, ncur, pral)
pro_cur(notas, nalum, ncur, prcu)
Console.WriteLine(" ")
Console.ForegroundColor = ConsoleColor.Yellow
proalumnos(pral, nalum)
procurso(prcu, ncur)
RANKING(nomalum, pral, nalum)
Console.ReadLine()
End Sub
End Module

3-

LA
TINKA

Module Module1
Sub ingresa(ByRef n As Integer)
Console.Write("INGRESE EL NRO 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 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 mostrar(ByVal a() As Integer, ByVal n As Integer)
Dim i As Integer
Console.ForegroundColor = ConsoleColor.Cyan
Console.WriteLine("
")
Console.WriteLine("
JUGADA GANADORA
For i = 0 To n - 1
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 + 30)
Console.WriteLine("{0}", A(Z))
Next
End Sub
Sub texto()
Dim x As Integer
Console.SetCursorPosition(30, 0)
Console.WriteLine(" PROGRAMA TINKA")
Console.SetCursorPosition(2, 2)
Console.WriteLine("CODIGO")
Console.SetCursorPosition(32, 2)
Console.WriteLine(" JUGADAS ")
Console.SetCursorPosition(67, 2)
Console.WriteLine("ACIERTOS")
Console.SetCursorPosition(4, 31)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("GANADORES CON 1 ACIERTO: ")
Console.SetCursorPosition(4, 32)
Console.WriteLine("GANADORES CON 2 ACIERTOS: ")
Console.SetCursorPosition(4, 33)
Console.WriteLine("GANADORES CON 3 ACIERTOS: ")
Console.SetCursorPosition(4, 34)
Console.WriteLine("GANADORES CON 4 ACIERTOS: ")
Console.SetCursorPosition(4, 35)
Console.WriteLine("GANADORES CON 5 ACIERTOS: ")
Console.SetCursorPosition(4, 36)
Console.WriteLine("GANADORES CON 6 ACIERTOS: ")
End Sub
Sub Main()
Dim n As Integer
Console.WriteLine("PROGRAMA LA TINKA")
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, 3)
mostrarv(c, n, 70)
mostrar(jg, 7)
texto()

")

FRECUENCIA(c, A, n)
Console.ReadLine()
End Sub
End Module

4- PARA UN EXAMEN DE ADMISION CON 60


PREGUNTAS
Module Module1
Sub nalum(ByRef n As Integer)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("Ingrese el numero de alumnos")
n = Console.ReadLine
End Sub
Sub puntajes(ByVal n As Integer, ByVal m As Integer)
Dim cod(n) As Integer
Dim y, w, c, R As Integer
Dim x As Double
For x = 0 To (n * 100)
w = (Rnd() * 10000 - 1) + 1
c=0
For y = 0 To n - 1
If cod(y) = w Then
c=1
End If
Next
If c = 0 Then
For R = 0 To n
If cod(R) = 0 Then
cod(R) = w
R=n+1
End If
Next

End If
Next
Dim ptj(n, m) As Integer
Dim puntos(n) As Integer
Dim puntaje As Integer = 0
Dim z As Integer
Dim vector(n, 0) As Integer
For z = 0 To m - 1
vector(n, 0) = Rnd() * 4 + 1
Console.ForegroundColor = ConsoleColor.Green
Console.WriteLine("La respuesta de la pregunta {0} es {1}", z + 1, vector(n, 0))
Next
For x = 0 To n - 1
puntaje = 0
For y = 0 To m - 1
ptj(x, y) = Rnd() * 4 + 1
If ptj(x, y) = vector(n, 0) Then
puntaje = puntaje + 1
End If
Next
puntos(x) = puntaje
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("El puntaje del alumno con codigo {0} es {1}", cod(x), puntos(x))
Next
Dim ind As Integer = 0
Dim maynota As Integer = 0
Dim pos As Integer = 0
Dim rank(n) As Integer
Dim l As Integer
For l = 0 To 2
maynota = 0
For ind = 0 To n - 1
If puntos(ind) > maynota Then
maynota = puntos(ind)
pos = ind
End If
rank(l) = maynota
Next
Console.WriteLine("El puesto {0} lo ocupa el codigo {1} con un puntaje de {2}", (l + 1), cod(pos),
rank(l))
puntos(pos) = 0
Next
End Sub
Sub Main()
Randomize()
Dim n As Integer
Dim m As Integer = 60
Dim puntaje As Integer = 0
Dim v(n) As Integer
nalum(n)
Dim vector(n, 0) As Integer
Dim Matriz(n, m) As Integer
Dim cod(n, 0) As Integer
puntajes(n, m)
Console.ReadLine()
End Sub
End Module

You might also like