UNIDAD 3:PASCAL ARREGLOS

TEMA 6: ARREGLOS TIPO TABLA PASCAL

Un arreglo tipo tabla se define como un conjunto de datos del mismo tipo organizados en dos o mas columnas y uno o mas renglones.

Para procesar ( recordar solo operaciones y comparaciones) internamente todos los elementos de la tabla se ocupan dos ciclos for() uno externo para controlar renglon y uno interno para controlar columna.

Los elementos de la tabla se deberan simbolizar con el nombre de la tabla y 2 subindices, el primer subindice referencia al renglon y el siguiente subindice referencia la columna.

La declaracion de una tabla sera de acuerdo al siguiente formato.

Nomtabla : array[1..cantren,1..cantcol]of tipodato;

ejemplo:

calif : array[1..3,1..4] of integer;

ciudades: array[1..3,1..4] of string[20];

Para efectuar procesos tales como operaciones despliegue con todos los elementos de la tabla se deberan usar 2 ciclos un for externo para controlar renglon y un for interno para controlar columna.

Prog8.pas


program prog8;

USES crt;

VAR

calif : ARRAY[1..3,1..2] of integer;

r,c,nc:integer;

begin

nc :=5;

clrscr;

(* captura tabla *)

for r := 1 to 3 do

begin

for c := 1 to 2 do

begin

gotoxy(nc,r+2);write('calif ',r,c,' :'); readln(calif[r,c]);

nc:=nc+20;

end;

nc:=5

end;

(* regalando 10 puntos a la calif *)

for r := 1 to 3 do

for c := 1 to 2 do

calif[r,c] := calif[r,c] + 10;

(* despliegue arreglo *)

for r := 1 to 3 do

begin

for c := 1 to 2 do

begin

gotoxy(nc,r+7);write('calif= ',calif[r,c]);

nc:=nc+20;

end;

nc:=5;

end;

readln;

end.

corrida:

image240.jpg

tareas PROGRAMACION PASCAL

1.- CONSTRUIR UN CUADRO QUE CONTENGA LOS COSTOS FIJOS DE CUATRO PRODUCTOS CUALESQUIERA, QUE SE PRODUCEN EN TRES PLANTAS DIFERENTES DE UNA EMPRESA MAQUILADORA.

2.- CONSTRUIR UN CUADRO QUE CONTENGA LOS INGRESOS MENSUALES POR VENTAS DURANTE LOS TRES PRIMEROS MESES DEL ANO DE CUATRO SUCURSALES DE UNA CADENA DE AUTO REFACCIONES, AGREGAR AL FINAL UNA LISTA QUE MUESTRE LOS INGRESOS MENSUALES TOTALES POR MESES Y UNA SEGUNDA LISTA QUE MUESTRE LOS INGRESOS MENSUALES TOTALES POR SUCURSAL.

3.-CONSTRUIR UN CUADRO QUE CONTENGA LAS COMISIONES GANADAS POR TRES VENDEDORES, DE LOS 5 TIPOS DE LINEA BLANCA DE CONOCIDA MUEBLERIA, ADEMAS LISTAS DE COMISIONES TOTALES Y PROMEDIOS GANADAS POR LOS VENDEDORES, ASI COMO LISTAS DE COMISIONES TOTALES Y PROMEDIOS POR TIPO DE LINEA BLANCA.

ANALIZAR ESTE CODIGO:


' PARA TOTALES Y PROMEDIOS POR RENGLON

FOR R = 0 TO 3

FOR C = 0 TO 2

TOTRENG(R) = TOTRENG(R) + TABLA(R,C)

NEXT C

PROMRENG(R) = TOTRENG(R)/3

NEXT R

'PARA TOTALES Y PROMEDIOS POR COLUMNA

FOR C = 0 TO 2

FOR R = 0 TO 3

TOTCOL(C)=TOTCOL(C) + TABLA(R,C)

NEXT R

PROMCOL(C) = TOTCOL(C) / 4

NEXT C

SUGERENCIA: CONSTRUIR PRIMERO LOS CUADROS EN PAPEL.

 




Google
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Politica de Privacidad