You are on page 1of 4

TALLER

ARREGLOS N-DIMENSIONALES
-------------------------------------------------------------------------------------------------------
Un docente que tiene a cargo M asignaturas necesita ordenar las calificaciones definitivas en orden
ascendente e imprimirlas por asignaturas.
-------------------------------------------------------------------------------------------------------
1. Dominio del Problema.
Ordenar e imprimir las notas de manera ascendente por asignaturas.
2. Anlisis.
2.1. Datos de Entrada:
ENTERO:m= Cantidad de asignaturas
CADENA:M[1..m]= Arreglo que contiene los nombres de las m asignaturas
ENTERO:n= Cantidad de notas
ENTERO:N[1..n]= Arreglo que contiene cantidad de notas por asignatura
REAL:NA[1..N[i]]= Arreglo que contiene todas las notas por asignatura
2.2. Datos de Salida:
REAL:NOTAS[1..N[i],1..m] = Arreglo que contiene N[i] cantidad de notas por m asignaturas
2.3. Datos auxiliares:
REAL:T= Variable que contiene el valor de la nota temporalmente
ENTERO:i,j,k= iteradores
2.4. Procesos
1. Leer m
2. Iniciar i hasta m, leer M[i]. Finalizar i.
3. Iniciar i hasta m, leer N[i].
4. Iniciar j hasta N[i], leer NA[j]. Finalizar j.
5. Iniciar j hasta N[i], ordenar ascendente NA[j]. NOTAS[j,i] NA[j]. Finalizar j. Finalizar i.
6. Iniciar i hasta m, Iniciar j hasta N[i], escribir NOTAS[j,i]. Finalizar j. Finalizar i.
3. Representacin de la alternativa de solucin en un estndar.
ALGORITMO NOTAS
VARIABLES
ENTERO: m, n, A[1..n], i, j, k
REAL: NA[1..N[i]], NOTAS[1..N[i],1..m],T
CADENA: M[1..m];
FIN_VARIABLES
INICIO
ESCRIBIR (Cantidad de asignaturas?)
LEER (m)
DESDE (i 1, m, INCREMENTO 1)
ESCRIBIR (Nombre de la asignatura,i,?)
LEER (M[i])
FIN_DESDE
DESDE (i 1, m, INCREMENTO 1)
ESCRIBIR (Cantidad de notas para la asignatura,M[i],?)
LEER (N[i])
DESDE (j 1, N[i], INCREMENTO 1)
ESCRIBIR (Digite la nota,j,de la asigM[i])
LEER (NA[j])
FIN_DESDE
DESDE (k 1, N[i]-1, INCREMENTO 1)
DESDE (j k+1, N[k], INCREMENTO 1)
SI (NA[j] > NA[k]) ENTONCES
TNA[j]
NA[j] NA[k]
NA[k]T
FIN_SI
FIN_DESDE
FIN_DESDE
DESDE (j 1, N[i], INCREMENTO 1)
NOTAS[j,i]NA[j]
FIN_DESDE
FIN_DESDE
DESDE (i 1, m, INCREMENTO 1)
DESDE (j 1, N[i], INCREMENTO 1)
ESCRIBIR(Nota,j,:,NOTAS[j,i])
FIN_DESDE
FIN_DESDE
FIN_INICIO
FIN_ALGORITMO

4. Prueba de escritorio.
SOLUCIN QUIZ 2
ARREGLOS UNIDIMENSIONALES
-------------------------------------------------------------------------------------------------------
01. Dado dos arreglos Arreglo1 y Arreglo2 unidimensionales de N elementos cada uno, obtener un arreglo
Arreglo3 unidimensional diferente donde su posicin i almacene la suma de Arreglo1[i]+Arreglo2[i] y
mostrar el mayor elemento del Arreglo3[i] y su posicin.
-------------------------------------------------------------------------------------------------------
1. Dominio del Problema
A partir de 2 arreglos unidimensionales obtener un tercero sumando los elementos en la misma
posicin de los 2 arreglos iniciales y del tercero seleccionar el mayor y su posicin.
2. Anlisis
2.1. Datos de Entrada:
ENTERO: N
REAL : Arreglo1[1..N], Arreglo2[1..N]
2.2. Datos de Salida:
REAL : mayor
ENTERO: mayor_indice
2.3. Datos auxiliares:
ENTERO: ndice
REAL : Arreglo3, suma
2.4. Procesos
1. Leer el tamao (N) de los arreglos 1 y 2.
2. Leer los datos de los arreglos 1 y 2.
3. Desde i=1 hasta N, sumaarreglo1[i]+arreglo2[i]
4. Arreglo3[i] suma
3. Representacin de la alternativa de solucin en un estndar.
ALGORITMO Arreglos
VARIABLE
REAL Arreglo1[1..N], Arreglo2[1..N], Arreglo3[1..N]
ENTERO ndice, mayor_indice, N
REAL suma, mayor
FIN_VARIABLE
INICIO
LEER (N)
DESDE (indice 1, N, INCREMENTO 1)
ESCRIBIR (Introduce un nmero para el vector Arreglo1)
LEER (Arreglo1[indice])
ESCRIBIR (Introduce un nmero para el vector Arreglo2)
LEER (Arreglo2[indice])
Suma (Arreglo1[indice] + Arreglo2[indice])
Arreglo3[indice] suma
FIN_DESDE
mayor Arreglo3[1]
mayor_indice 1
DESDE (indice 1, N, INCREMENTO 1)
SI (Arreglo3[indice] > mayor) ENTONCES
mayor_indice indice
mayor Arreglo3[indice]
FIN_SI
FIN_DESDE
ESCRIBIR (mayor)
ESCRIBIR (mayor_indice)
FIN_INICIO
FIN_ALGORITMO
4. Prueba de escritorio.

i Arreglo1 Arreglo2 Arreglo3 suma mayor mayor_indice


1 60 60 120 120 120 1
2 50 50 100 100 120 1
3 40 60 100 100 120 1
4 20 30 50 50 120 1
5 60 80 140 140 140 5

You might also like