You are on page 1of 10

Universidad Nacional de San Agustín

FACULTAD DE INGENIERIA DE PRODUCCION Y


SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA
INDUSTRIAL

CURSO:
PROGRAMACION Y METODOS
NUMERICOS

DOCENTE:
ING. JUAN CARLOS TORREBLANACA

INTEGRANTE:
 --APAZA CALLA, GLENNY BRIGHIT

- GRUPO: “A”

AREQUIPA - PERU
2017
MENU DE COLAS Y PILAS
Module Module1
Sub main()
Dim opc As Single
Do
opc = menuS()
Select Case opc
Case 1
Console.Clear()
colas()
Case 2
Console.Clear()
pilas()
Case 3
fin()
End Select
Console.ReadLine()
Loop While (opc <= 3)
End Sub
Function menuS()
Dim opc As Single
Console.Clear()
marco()
Console.SetCursorPosition(25, 4)
Console.ForegroundColor = ConsoleColor.Cyan
Console.Write(" MENÚ PRINCIPAL ")
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(5, 6)
Console.Write(" 1. COLAS")
Console.SetCursorPosition(5, 7)
Console.Write(" 2. PILAS ")
Console.SetCursorPosition(5, 8)
Console.Write(" 3. FIN ")
Console.SetCursorPosition(5, 9)
Console.Write("Escoge una opción: ")
opc = Console.ReadLine
Return (opc)
End Function
Sub marco()
Dim a As Single
Console.Clear()
For a = 5 To 55 Step 1
Console.ForegroundColor = ConsoleColor.Maganta
Console.SetCursorPosition(a, 16)
Console.Write("*")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(a, 2)
Console.Write("*")
Next
For a = 2 To 16 Step 1
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(2, a)
Console.Write("*")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(58, a)
Console.Write("*")
Next
End Sub
Sub colas()
Dim n, op As Single
Const p As Integer = 1000
Dim cola(p) As String
Console.ForegroundColor = ConsoleColor.Cyan
Do
menu(op)
Select Case (op)
Case 1
MOSTRAR_COLA(n, cola)
Case 2
ENTRAR(n, cola)
Case 3
SALIR(n, cola)
Case 4
Exit Do
End Select
Loop While (op <= 4)
Console.Clear()
End Sub
Sub menu(ByRef op As Integer)
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(25, 3)
Console.Write("MENU DE COLAS")
Console.SetCursorPosition(5, 5)
Console.Write("1. MOSTRAR ")
Console.SetCursorPosition(5, 6)
Console.Write("2. INGRESAR ")
Console.SetCursorPosition(5, 7)
Console.Write("3. SALIR ")
Console.SetCursorPosition(5, 8)
Console.Write("4. FIN")
Console.SetCursorPosition(5, 10)
Console.Write("ESCOGER OPCIÓN: ")
op = Console.ReadLine
Console.Clear()
End Sub
Sub MOSTRAR_COLA(ByRef n As Integer, ByVal cola() As String)
Console.Clear()
If (n > 0) Then
Console.SetCursorPosition(2, 4)
Console.Write("LA COLA ESTA ORDENADA DE LA SIGUIENTE MANERA: ")
Console.SetCursorPosition(4, 6)
For a = 0 To n - 1 Step 1
Console.Write("[{0}] {1} <<< ", a + 1, cola(a))
Next
Console.ReadLine()
Else
Console.SetCursorPosition(2, 4)
Console.WriteLine("NO HAY NADIE FORMANDO COLA")
Console.ReadLine()
End If
End Sub
Sub ENTRAR(ByRef n As Single, ByRef cola() As String)
Console.Clear()
n = n + 1
Dim temporal(n) As String
For c = 0 To n - 2 Step 1
temporal(c) = cola(c)
Next
Console.SetCursorPosition(2, 4)
Console.Write("INGRESAR NOMBRE: ")
Console.SetCursorPosition(4, 6)
temporal(n - 1) = Console.ReadLine
For c = 0 To n - 1 Step 1
cola(c) = temporal(c)
Next
End Sub
Sub SALIR(ByRef n As Single, ByVal cola() As String)
If (n > 0) Then
Dim persona As String
Dim temporal(n) As String
persona = cola(0)
n = n - 1
For c = 0 To n - 1 Step 1
temporal(c) = cola(c + 1)
Next
For c = 0 To n - 1 Step 1
cola(c) = temporal(c)
Next
Console.SetCursorPosition(2, 4)
Console.WriteLine("QUIEN QUE SALE DE LA COLA ES: {0} ", persona)
Else
Console.SetCursorPosition(2, 4)
Console.WriteLine("NO HAY NADIE FORMANDO COLA")
End If
Console.ReadLine()
Console.Clear()
End Sub
Sub pilas()
Dim n, opc As Single
Dim p As Integer = 1000
Dim serie(p) As String
Console.ForegroundColor = ConsoleColor.Cyan
Do
Menu2(opc)
Select Case (opc)
Case 1
MOSTRAR_SERIE(n, serie)
Case 2
ENTRAR1(n, serie)
Case 3
SALIR1(n, serie)
Case 4
Exit Do
End Select
Loop While (opc <= 4)
End Sub
Sub Menu2(ByRef opc As Integer)
Console.Clear()
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(25, 3)
Console.Write("MENU DE PILAS")
Console.SetCursorPosition(5, 5)
Console.Write("1. MOSTRAR ")
Console.SetCursorPosition(5, 6)
Console.Write("2. INGRESAR ")
Console.SetCursorPosition(5, 7)
Console.Write("3. SALIR ")
Console.SetCursorPosition(5, 8)
Console.Write("4. FIN")
Console.SetCursorPosition(5, 10)
Console.Write("ESCOGER OPCIÓN: ")
opc = Console.ReadLine
Console.Clear()
End Sub
Sub MOSTRAR_SERIE(ByRef n As Integer, ByVal serie() As String)
Console.Clear()
Dim b, m As Integer
If (n > 0) Then
Console.SetCursorPosition(2, 4)
Console.Write("LA SERIE ESTA ORDENADA DE LA SIGUIENTE MANERA")
b = 12
m = 5
For a = 0 To n - 1 Step 1
Console.SetCursorPosition(10, b + m)
Console.Write("{0} - {1}", a + 1, serie(a))
b = b - 1
m = m - 1
Next
Console.ReadLine()
Else
Console.SetCursorPosition(2, 4)
Console.WriteLine("NO HAY NINGUNA PILA ")
Console.ReadLine()
End If
End Sub
Sub ENTRAR1(ByRef n As Single, ByRef serie() As String)
Console.Clear()
n = n + 1
Dim temporal(n) As String
For c = 0 To n - 2 Step 1
temporal(c) = serie(c)
Next
Console.SetCursorPosition(2, 4)
Console.Write("INGRESAR PILA")
Console.SetCursorPosition(4, 6)
temporal(n - 1) = Console.ReadLine
For c = 0 To n - 1 Step 1
serie(c) = temporal(c)
Next
End Sub
Sub SALIR1(ByRef n As Single, ByVal serie() As String)
If (n > 0) Then
Dim pila As String
Dim temporal(n) As String
pila = serie(n - 1)
n = n - 1
For c = 0 To n - 1 Step 1
temporal(c) = serie(c)
Next
For c = 0 To n - 1 Step 1
serie(c) = temporal(c)
Next
Console.SetCursorPosition(2, 4)

Console.WriteLine("LA PILA QUE SALE ES: {0} ", pila)


Else
Console.SetCursorPosition(2, 4)
Console.WriteLine("NO HAY NINGUNA PILA ")
End If
Console.ReadLine()
Console.Clear()
End Sub
Sub fin()
Dim a As Single
Console.Clear()
For a = 6 To 50 Step 1
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(a, 10)
Console.Write("*")
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(a, 2)
Console.Write("*")
Next
For a = 3 To 9 Step 1
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(4, a)
Console.Write("*")
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(52, a)
Console.Write("*")
Next
Console.ForegroundColor = ConsoleColor.Cyan
Console.SetCursorPosition(15, 5)
Console.Write(" FIN ")

End Sub
End Module

MENU DE notas
Module Module1

Sub Main()
Dim n, o As Integer
n = 3
Dim nota(n) As Integer
Dim nombre(n) As String
Do
marco()
menu()
o = Console.ReadLine
Console.Clear()
Select Case o
Case 1
Datos(nombre, nota, n)
Console.Clear()
Case 2
notamayor(nombre, nota, n)
Console.Clear()
Case 3
notamenor(nombre, nota, n)
Console.Clear()
Case 4
apro_desa(nota, n)
Console.Clear()
Case 5
frecuencia(nota, n)
Console.Clear()
Case 6
moda_Fre(nota, n)
Console.Clear()
Case 7 = False
End Select
Loop While o < 7
End Sub
Sub Datos(ByRef b() As String, ByRef t() As Integer, ByVal a As Integer)
Dim x As Integer
For x = 0 To a - 1
Titulo()
Console.Write("INGRESAR NOMBRE: ")
b(x) = Console.ReadLine
Console.Write("INGRESAR NOTA: ")
t(x) = 1 + Rnd() * 20
Console.Write("{0}", t(x))
Console.ReadLine()
Console.WriteLine("")
Console.Clear()
Next
End Sub
Sub notamayor(ByVal b() As String, ByVal t() As Integer, ByVal a As Integer)
marco()
Console.SetCursorPosition(34, 3)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("NOTA MAYOR")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(3, 5)

Dim i, q As Integer
q = 0
For i = 0 To a - 1
If t(i) > q Then
q = t(i)
End If
Next
For i = 0 To a - 1
If t(i) = q Then
Console.SetCursorPosition(3, 5)
Console.ForegroundColor = ConsoleColor.Mgenta
Console.WriteLine("{0} tiene la nota mayor, y es: {1}", b(i), t(i))
End If
Next
Console.ReadLine()
End Sub

Sub notamenor(ByVal b() As String, ByVal t() As Integer, ByVal a As Integer)


marco()
Console.SetCursorPosition(34, 3)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("NOTA MENOR")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(3, 5)
Dim i, q As Integer
q = 1000
For i = 0 To a - 1
If t(i) < q Then
q = t(i)
End If
Next
For i = 0 To a - 1
If t(i) = q Then
Console.SetCursorPosition(3, 5)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("{0} TIENE LA NOTA MAYOR, Y ES: {1}", b(i), t(i))
End If
Next
Console.ReadLine()
End Sub
Sub apro_desa(ByVal t() As Integer, ByVal a As Integer)
Dim ap, d, i As Integer
ap = 0
d = 0
For i = 0 To a - 1
If t(i) > 10.5 Then
ap = ap + 1
Else
d = d + 1
End If
Next
marco()
Console.SetCursorPosition(27, 3)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("APROBADOS Y DESAPROBADOS")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(3, 5)
Console.WriteLine("NUMERO DE APROBADOS: {0}", ap)
Console.SetCursorPosition(3, 6)
Console.WriteLine("NUMERO DE DESAPROBADOS: {0}", d)
Console.ReadLine()
End Sub
Sub moda_Fre(ByVal t() As Integer, ByVal a As Integer)
Dim i, aa, ii, c, m, mi As Integer
m = 0
aa = 20
Dim p(aa) As Integer
For i = 0 To aa
c = 0
For ii = 0 To a - 1
If i = t(ii) Then
c = c + 1
End If
Next ii
p(i) = c
If p(i) > m Then
m = p(i)
mi = i
End If
Next
marco()
Console.SetCursorPosition(37, 3)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("MODA")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(3, 5)
Console.WriteLine("LA MODA ES: {0}", mi)
Console.ReadLine()
End Sub
Sub frecuencia(ByVal t() As Integer, ByVal a As Integer)
marco()
Console.SetCursorPosition(34, 3)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("FRECUENCIA")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(0, 5)
Dim i, aa, ii, c As Integer
aa = 20
Dim p(aa) As Integer
For i = 0 To aa
c = 0
For ii = 0 To a - 1
If i = t(ii) Then
c = c + 1
End If
Next ii
p(i) = c
If p(i) > 0 Then
Console.WriteLine("LA FRECUENCIA F({0}) = {1}", i, p(i))
End If
Next
Console.ReadLine()
End Sub
Sub menu()
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(35, 3)
Console.WriteLine("ALUMNOS")
Console.SetCursorPosition(3, 6)
Console.WriteLine("1. DATOS ALEATORIOS")
Console.SetCursorPosition(3, 7)
Console.WriteLine("2. NOTA MAYOR")
Console.SetCursorPosition(3, 8)
Console.WriteLine("3. NOTA MENOR")
Console.SetCursorPosition(3, 9)
Console.WriteLine("4. APROBADOS Y DESAPROBADOS")
Console.SetCursorPosition(3, 10)
Console.WriteLine("5. FRECUENCIA")
Console.SetCursorPosition(3, 11)
Console.WriteLine("6. MODA")
Console.SetCursorPosition(3, 13)
Console.WriteLine("7. SALIR")
Console.SetCursorPosition(3, 14)
Console.Write("ESCOGER OPCION: ")

End Sub
Sub Titulo()
marco()
Console.SetCursorPosition(31, 3)
Console.ForegroundColor = ConsoleColor.Magenta
Console.WriteLine("DATOS ALEATORIOS")
Console.ForegroundColor = ConsoleColor.Magenta
Console.SetCursorPosition(3, 5)
End Sub
Sub marco()
Dim c, d As Integer
Console.ForegroundColor = ConsoleColor.Cyan
For c = 1 To 78
Console.SetCursorPosition(c, 1)
Console.WriteLine("*")
Console.SetCursorPosition(c, 23)
Console.WriteLine("*")
Next
For d = 1 To 23
Console.SetCursorPosition(1, d)
Console.WriteLine("*")
Console.SetCursorPosition(78, d)
Console.WriteLine("*")
Next
End Sub
End Module

You might also like