Aca les dejo, la segunda completa, con todos los reportes y con el error de lectura corregido
Descargar Segunda pregunta completa
Mostrando entradas con la etiqueta progra II. Mostrar todas las entradas
Mostrando entradas con la etiqueta progra II. Mostrar todas las entradas
Examen Progra II
Para aquellos que van a dar examen de Progra II, aca les dejo el desarrollo del examen del ciclo pasado.. en VisualBasic
Descargar Primera Pregunta
Descargar Segunda Pregunta
SUERTE.... EN TU EXAMEN... QUE LA VAS A NECESITAR
Dejar tu comentario, no cuesta nada =P
Ejercicio de Vectores en VB
Ejercicio de Vectores en Visual Basic, de la calse del profesro Valdivia
Sub main()
Dim nombres() As String
Dim total As Integer
Lectura nombres, total
Procesar nombres, total
Presenta nombres, total
End Sub
Sub Lectura(nombres() As String, total As Integer)
Dim cad As String
Dim sw As String
Do
cad = InputBox("Ingrese nombre: ")
Agregar nombres, total, cad
Do
sw = InputBox("Desea continuar?" & vbCrLf & "Si" & vbCrLf & "No")
Loop Until (sw = "si" Or sw = "no")
Loop Until sw = "no"
End Sub
Sub Agregar(nombres() As String, total As Integer, cad As String)
ReDim Preserve nombres(total)
nombres(total) = cad
total = total + 1
End Sub
Sub Presenta(nombres() As String, total As Integer)
Dim i As Integer
Dim cad As String
For i = 0 To total - 1
cad = cad & nombres(i) & vbCrLf
Next
MsgBox (cad)
End Sub
Sub Procesar(nombres() As String, total As Integer)
Dim i As Integer
Dim j As Integer
Dim aux As String
For i = 0 To total - 2
For j = i + 1 To total - 1
If nombres(i) > nombres(j) Then
aux = nombres(i)
nombres(i) = nombres(j)
nombres(j) = aux
End If
Next
Next
End Sub
Sub main()
Dim nombres() As String
Dim total As Integer
Lectura nombres, total
Procesar nombres, total
Presenta nombres, total
End Sub
Sub Lectura(nombres() As String, total As Integer)
Dim cad As String
Dim sw As String
Do
cad = InputBox("Ingrese nombre: ")
Agregar nombres, total, cad
Do
sw = InputBox("Desea continuar?" & vbCrLf & "Si" & vbCrLf & "No")
Loop Until (sw = "si" Or sw = "no")
Loop Until sw = "no"
End Sub
Sub Agregar(nombres() As String, total As Integer, cad As String)
ReDim Preserve nombres(total)
nombres(total) = cad
total = total + 1
End Sub
Sub Presenta(nombres() As String, total As Integer)
Dim i As Integer
Dim cad As String
For i = 0 To total - 1
cad = cad & nombres(i) & vbCrLf
Next
MsgBox (cad)
End Sub
Sub Procesar(nombres() As String, total As Integer)
Dim i As Integer
Dim j As Integer
Dim aux As String
For i = 0 To total - 2
For j = i + 1 To total - 1
If nombres(i) > nombres(j) Then
aux = nombres(i)
nombres(i) = nombres(j)
nombres(j) = aux
End If
Next
Next
End Sub
Ejercicio Progra II
El Ejercicio de progra II, con el profesor Valvidia
Sub main()
Dim opc As Integer
Do
opc = InputBox("1: Numeros" & vbCrLf & "2: Factorial" & vbCrLf & "3: Dias de mes" & vbCrLf & "4: Salir")
Select Case opc
Case 1: uno
Case 2: dos
Case 3: tres
End Select
Loop Until opc = 4
End Sub
Sub uno()
Dim numero As Integer
Dim mayor As Integer
Dim menor As Integer
Dim promedio As Double
Dim suma As Integer
Dim n As Integer
Dim sw As Integer
suma = 0
sw = 0
n = 0
Do
numero = InputBox("Ingrese numero: ")
If sw = 0 Then
mayor = numero
menor = numero
sw = 1
End If
If numero <> 0 Then
n = n + 1
End If
If numero > mayor Then
mayor = numero
End If
If numero < menor And numero <> 0 Then
menor = numero
End If
suma = suma + numero
Loop Until numero = 0
If n <> 0 Then
promedio = suma / n
End If
MsgBox ("Cantidad: " & n & vbCrLf & "Mayor: " & mayor & vbCrLf & "Menor: " & menor & vbCrLf & "Promedio: " & promedio)
End Sub
Function factorial(n As Integer) As Integer
Dim fact As Integer
Dim i As Integer
fact = 1
If (n = 0) Then
fact = 1
Else
For i = 1 To n
fact = fact * i
Next
End If
factorial = fact
End Function
Sub dos()
Dim numero As Integer
Dim fact As Integer
numero = InputBox("Ingrese numero: ")
If numero < 0 Then
MsgBox ("No hay factorial de negativos")
Else
fact = factorial(numero)
MsgBox ("Factorial de " & numero & " es " & fact)
End If
End Sub
Sub cantidad(mes As String, ByRef c As Integer)
Select Case mes
Case "enero": c = 31
Case "febrero": c = 28
Case "marzo": c = 31
Case "abril": c = 30
Case "mayo": c = 31
Case "junio": c = 30
Case "julio": c = 31
Case "agosto": c = 31
Case "setiembre": c = 30
Case "octubre": c = 31
Case "noviembre": c = 30
Case "diciembre": c = 31
End Select
End Sub
Sub tres()
Dim mes As String
Dim dias As Integer
dias = 0
Do
mes = InputBox("Ingrese mes: ")
cantidad mes, dias
Loop Until dias > 0
MsgBox (mes & " tiene " & dias & " dias")
End Sub
Sub main()
Dim opc As Integer
Do
opc = InputBox("1: Numeros" & vbCrLf & "2: Factorial" & vbCrLf & "3: Dias de mes" & vbCrLf & "4: Salir")
Select Case opc
Case 1: uno
Case 2: dos
Case 3: tres
End Select
Loop Until opc = 4
End Sub
Sub uno()
Dim numero As Integer
Dim mayor As Integer
Dim menor As Integer
Dim promedio As Double
Dim suma As Integer
Dim n As Integer
Dim sw As Integer
suma = 0
sw = 0
n = 0
Do
numero = InputBox("Ingrese numero: ")
If sw = 0 Then
mayor = numero
menor = numero
sw = 1
End If
If numero <> 0 Then
n = n + 1
End If
If numero > mayor Then
mayor = numero
End If
If numero < menor And numero <> 0 Then
menor = numero
End If
suma = suma + numero
Loop Until numero = 0
If n <> 0 Then
promedio = suma / n
End If
MsgBox ("Cantidad: " & n & vbCrLf & "Mayor: " & mayor & vbCrLf & "Menor: " & menor & vbCrLf & "Promedio: " & promedio)
End Sub
Function factorial(n As Integer) As Integer
Dim fact As Integer
Dim i As Integer
fact = 1
If (n = 0) Then
fact = 1
Else
For i = 1 To n
fact = fact * i
Next
End If
factorial = fact
End Function
Sub dos()
Dim numero As Integer
Dim fact As Integer
numero = InputBox("Ingrese numero: ")
If numero < 0 Then
MsgBox ("No hay factorial de negativos")
Else
fact = factorial(numero)
MsgBox ("Factorial de " & numero & " es " & fact)
End If
End Sub
Sub cantidad(mes As String, ByRef c As Integer)
Select Case mes
Case "enero": c = 31
Case "febrero": c = 28
Case "marzo": c = 31
Case "abril": c = 30
Case "mayo": c = 31
Case "junio": c = 30
Case "julio": c = 31
Case "agosto": c = 31
Case "setiembre": c = 30
Case "octubre": c = 31
Case "noviembre": c = 30
Case "diciembre": c = 31
End Select
End Sub
Sub tres()
Dim mes As String
Dim dias As Integer
dias = 0
Do
mes = InputBox("Ingrese mes: ")
cantidad mes, dias
Loop Until dias > 0
MsgBox (mes & " tiene " & dias & " dias")
End Sub
Suscribirse a:
Entradas (Atom)
