UNIVERSIDAD DE PANAMÁ
CENTRO REGIONAL DE AZUERO
FACULTAD DE INGENIERÍA INDUSTRIAL
INGENIERÍA INDUSTRIAL
NOMBRE DEL PROFESOR:
JOSÉ RUÍZ
ESTUDIANTES
MARÍA JOSÉ MEZA / 20-14-8385
CÉSAR VERGARA/ 7-713-1146
JESÚS RODRÍGUEZ/ 6-727-25
AYLIN RÍOS / 6-727-2333
PROGRAMACIÓN COMPUTACIONAL INDUSTRIAL
7II701
PARCIAL N°4
FECHA DE ENTREGA:
MARTES 25 DE JUNIO DE 2024
Ejercicio 9.2: Intercambio de los Elementos de un Vector.
Private Sub cmdintercambio_Click()
Dim mensaje As String
n = Val([Link])
If n > 100 Then
MsgBox (" La máxima cantidad de n es 100")
Exit Sub
End If
For i = 1 To n
mensaje = " Introduzca el valor de" & vbCrLf
mensaje = mensaje & "x(" & Str(i) & " ): "
x(i) = Val(InputBox(mensaje))
Next
If (-1) ^ n > 0 Then
m=n/2
Else
m = (n - 1) / 2
End If
k=n
For i = 1 To m
temp = x(i)
x(i) = x(k)
x(k) = temp
k=k-1
Next
For i = 1 To n
mensaje = "Impresión de valor" & vbCrLf
mensaje = mensaje & "x( " & Str(i) & " )= "
mensaje = mensaje & Str(x(i))
MsgBox (mensaje)
Next
End Sub
Ejercicio 9.6: Ordenamiento de los elementos de un vector.
Private Sub cmdordenar_vector_Click()
Dim x(100), num As Single
Dim i, j, k, n As Integer
Dim mensaje As String
n = Val([Link])
If n <= 0 Then
MsgBox ("Error, solo puede poner números mayores que 0")
Exit Sub
End If
If n > 100 Then
MsgBox (" n debe ser menor que 100")
Exit Sub
End If
For i = 1 To n
mensaje = " Introduzca el valor de" & vbCrLf
mensaje = mensaje & "x(" & Str(i) & "): "
x(i) = Val(InputBox(mensaje))
Next
For i = 1 To n - 1
num = x(i)
k=i
For j = i + 1 To n
If [Link] = True Then
If x(j) < num Then
num = x(j)
k=j
End If
Else
If x(j) > num Then
num = x(j)
k=j
End If
End If
Next
x(k) = x(i)
x(i) = num
Next
For i = 1 To n
mensaje = "Impresión de valor" & vbCrLf
mensaje = mensaje & "X(" & Str(i) & ")="
mensaje = mensaje & Str(x(i))
MsgBox (mensaje)
Next
End Sub
Ejercicio 10.1: Confeccione un programa que lea la matriz y luego
sume todos sus elementos.
Private Sub cmdsumar_todos_Click()
Dim a(50, 50), suma As Single
Dim i, j, filas, cols As Integer
Dim m, tit As String
filas = Val([Link])
cols = Val([Link])
If filas <= 0 Or cols <= 0 Then
MsgBox ("Error, solo puede poner números mayores que 0")
Exit Sub
End If
If filas >= 45 Or cols >= 45 Then
MsgBox ("Error, solo puede poner números menores que 49")
Exit Sub
End If
For i = 1 To filas
For j = 1 To cols
tit = " Lectura de la matriz"
m = "Datos de la fila No." & Str(i) & vbCrLf
m = m & "a(" & Str(i) & ", " & Str(j) & ")= "
a(i, j) = Val(InputBox(m, tit))
Next
Next
suma = 0
For i = 1 To filas
For j = 1 To cols
suma = suma + a(i, j)
Next
Next
[Link] = suma
End Sub