Você está na página 1de 31

Program Trabajo_Practico;

Uses
crt,dos;
Type
Entera = Array [1..256,1..3] of longint; {Tipo de matriz de enteros}
Reales = Array [1..256,1..2] of real; {Tipo de matriz de reales}
Caracter = Array [1..256,1..3] of char; {Tipo de matriz de
caracteres}
Var
d: integer;
MEntera: Entera; {Matriz de enteros para guardar fecha, numero de placa y
zona}
MReal: Reales; {Matriz de reales para guardar velocidad y multa}
MChar: Caracter; {Matriz de caracteres para guardar letras de la placa}
F_Actual: longint; {Variable para guardar la fecha actual}
Const
VLim = 80; {Velocidad minima en Km/h para poder registrar una
multa}
UT_Peso = 20; {Relaci�n entre la unidad tributaria y el peso}
UT_KM = 0.5; {Relaci�n entre la unidad tributaria y la velocidad
excedida}
Zonas = 4; {Cantidad de zonas}
Amin = 19000000; {A�o minimo}

{------------------------------------------------------------------------------}

Procedure Inicializacion (var ME:Entera; var MR:Reales; var MC:Caracter);


{Este procedure se encarga de incializar todas las matrices, por medio de un for y
tres for anidados a este}
var
i,k,l,t: integer; {Estas cuatro variables son utilizadas en los for}
Begin
For i := 1 to 256 do
Begin
For t := 1 to 3 do
MC[i,t] := 'A';
For K := 1 to 3 do
ME[i,k]:=0;
For l := 1 to 2 do
MR[i,l]:=0;
end;
end;

{---------------------------------------------------------------------------------
}

Procedure Invertir_Valores_reales(Var Valor1,Valor2:real);


{Estos tres procedures estan dise�ado para hacer la inversion de los valores.}
{Cada uno para un tipo de matriz distinta, cada uno tiene la misma logica}
Var
Aux : real; {Esta variable es utilizado para guardar un
valor que sera cambiado}
Begin
Aux := Valor1;
Valor1 := Valor2;
Valor2 := Aux;
end;

{---------------------------------------------------------------------------------
}

Procedure Invertir_Valores_enteros(Var Valor1,Valor2:longint);


Var
Aux : longint;
Begin
Aux := Valor1;
Valor1 := Valor2;
Valor2 := Aux;
end;

{---------------------------------------------------------------------------------
}

Procedure Invertir_Valores_char(Var Valor1,Valor2:char);


Var
Aux : char;
Begin
Aux := Valor1;
Valor1 := Valor2;
Valor2 := Aux;
end;

{-------------------------------------------------------------------------------}

Function CantDatos (MEntera: Entera) : integer;


{Esta funci�n devuelve la posici�n en la se encuentra la primera posicion para
llenar con valores}
var
i : integer;
Begin
i := 1;
While (MEntera[i,2]<>0) and (i < 256) do
Begin
i := i + 1;
end;
CantDatos := i ;
end;

{---------------------------------------------------------------------------------
------------------}

Procedure Ordenar_Por_Fecha(Var Mat1:Entera; Var Mat2:Reales; Var Mat3:Caracter);


{Este procedure se encarga de ordenar por fecha las tres matrices, utilizando el
metodo del burbujeo}
Var
I,J,N,P:Integer; {Las variables i, j y P son utilizados para contro de
los distintos for}
Begin
i := 0;
N := CantDatos(Mat1);
P := N - 1; {La variable P es la ultima posicion de la matriz en
la que hay un valor ingresado}
For i := 1 to P - 1 do
For J := 1 to P - i do
If (Mat1[J,3] > Mat1[J+1,3]) then
begin

Invertir_Valores_enteros(Mat1[J,1],Mat1[J+1,1]);

Invertir_Valores_enteros(Mat1[J,2],Mat1[J+1,2]);

Invertir_Valores_enteros(Mat1[J,3],Mat1[J+1,3]);
Invertir_Valores_reales(Mat2[J,1],Mat2[J+1,1]);
Invertir_Valores_reales(Mat2[J,2],Mat2[J+1,2]);
Invertir_Valores_char(Mat3[J,1],Mat3[J+1,1]);
Invertir_Valores_char(Mat3[J,2],Mat3[J+1,2]);
Invertir_Valores_char(Mat3[J,3],Mat3[J+1,3]);
end;
end;

{---------------------------------------------------------------------------------
------------------}

Procedure Ordenar_Por_Zona(Var Mat1:Entera; Var Mat2:Reales; Var Mat3:Caracter);


{Este procedure se encarga de ordenar por zona las tres matrices, utilizando el
metodo del burbujeo}
Var
i,N,j,P:Integer;
Begin
i := 0;
N := CantDatos(Mat1);
P := N - 1;
For i := 1 to P - 1 do
For J := 1 to P - i do
If (Mat1[J,2] > Mat1[J+1,2]) then
begin

Invertir_Valores_enteros(Mat1[J,1],Mat1[J+1,1]);

Invertir_Valores_enteros(Mat1[J,2],Mat1[J+1,2]);

Invertir_Valores_enteros(Mat1[J,3],Mat1[J+1,3]);
Invertir_Valores_reales(Mat2[J,1],Mat2[J+1,1]);
Invertir_Valores_reales(Mat2[J,2],Mat2[J+1,2]);
Invertir_Valores_char(Mat3[J,1],Mat3[J+1,1]);
Invertir_Valores_char(Mat3[J,2],Mat3[J+1,2]);
Invertir_Valores_char(Mat3[J,3],Mat3[J+1,3]);
end;
end;

{---------------------------------------------------------------------------------
------------------}

Procedure Ordenar_Por_Multa(Var Mat1:Entera; Var Mat2:Reales; Var Mat3:Caracter);


{Este procedure se encarga de ordenar por multa las tres matrices, utilizando el
metodo del burbujeo}
Var
i,j,N,P:Integer;
Begin
i := 0;
N := CantDatos(Mat1);
P := N - 1;
For i := 1 to P - 1 do
For J := 1 to P - i do
If (Mat2[J,2] > Mat2[J+1,2]) then
begin

Invertir_Valores_enteros(Mat1[J,1],Mat1[J+1,1]);

Invertir_Valores_enteros(Mat1[J,2],Mat1[J+1,2]);

Invertir_Valores_enteros(Mat1[J,3],Mat1[J+1,3]);
Invertir_Valores_reales(Mat2[J,1],Mat2[J+1,1]);
Invertir_Valores_reales(Mat2[J,2],Mat2[J+1,2]);
Invertir_Valores_char(Mat3[J,1],Mat3[J+1,1]);
Invertir_Valores_char(Mat3[J,2],Mat3[J+1,2]);
Invertir_Valores_char(Mat3[J,3],Mat3[J+1,3]);
end;
end;

{---------------------------------------------------------------------------------
-------------}

Function Validar_Reales:real;
{Esta funcion valida los reales, haciendo que solo guarde valores logicos para un
numero real}
Var
Validos : Set of Char;
Car : Char;
S : String [30];
Aux : Real;
Codigo : Integer;
Begin
S := '';
Validos := ['0'..'9','.',',','-'];
Car := ReadKey;
Repeat
If Car in Validos then
Begin
If '-' in Validos then Validos := Validos - ['-'];
If (Car = '.') or (Car = ',') then
Begin
Validos := Validos - [',','.'];
Car := '.';
end;
Write(Car);
S := S + Car
end;
Car := Readkey;
Until (Car = #13);
Val(S,Aux,Codigo);
Validar_Reales := Aux;
end;

{---------------------------------------------------------------------------------
----}

Function Validar_Enteros(i:integer):Integer;
{Esta funcion valida enteros, es una derivaci�n de la anterior funci�n quitandole
los valores '-' , ',' y '.'}
{El valor de i ingresado, sirve para decir que tan grande debe ser el entero y
limitar la cantidad de datos}
Var
Validos : Set of Char;
Car : Char;
S : String [4];
Aux,C : Integer;
Codigo : Integer;

Begin
S := '';
Validos := ['0'..'9'];
Car := ReadKey;
C := 0;
Repeat
If Car in Validos then
Begin
Write(Car);
C := C + 1;
S := S + Car
end;
Car := Readkey;
Until (Car = #13) or (C = i);
Val(S,Aux,Codigo);
Validar_Enteros := Aux;
end;

{---------------------------------------------------------------------------------
----}

Function Validar_Caracter:char;
{Esta funci�n valida los caracteres del abecedario ingles, en minuscula y
mayuscula}
Var
Validos : Set of Char;
Car : Char;
Begin
Validos := ['a'..'z','A'..'Z'];
Repeat
car := readkey;
If Car in Validos then
begin
Write(Car);
end;
Until Car in Validos;
Car:= UpCase(Car);
Validar_Caracter := Car;
readkey;
end;

{---------------------------------------------------------------------------------
----}

Function Validar_SN:char;
{Esta funcion es utilizada para restringir los valores ingresados a S/N}
Var
Validos : Set of Char;
Car : Char;
Begin
Validos := ['s','S','n','N'];
Repeat
car := readkey;
Until Car in Validos;
Validar_SN := Car;
end;

{-----------------------------------------------------------------------------
--------}

Function Vel : real;


{Esta funci�n es utilizada para pedir y verficar que la velocidad este limitada
por una velocidad maxima de 300 km/h}
{Se le coloca una cota minima de la constante vlim, para saber que apartir de ese
valor es una multa}
var
Velocidad:real;
R:char;
begin
Repeat
Clrscr;
Writeln('Ingrese la velocidad en Km/h:');
Velocidad := Validar_Reales;
While (Velocidad < VLim) or (Velocidad > 300) do
Begin
Clrscr;
Writeln('La velocidad ingresada esta fuera de rango;
Ingresar nuevamente:');
Velocidad := Validar_Reales;
end;
Clrscr;
Writeln('La velocidad ingresada es: ',Velocidad:6:3);
Writeln;
Writeln('�Desea Corregir? (S/N)');
R := Validar_SN;
Until (R = 'n') or (R = 'N');
Vel := Velocidad;
end;

{---------------------------------------------------------------------------------
---------------}

Function Validar_Zona (Zona:integer):Boolean;


{Esta funci�n est utilizada para verificar que la zona este entre 1 y el
maximo de zonas (la constante Zonas)}
Var
G : Boolean;
Begin
G := True;
If (Zona < 1) or (Zona > Zonas) then
G := False;
Validar_Zona := G;
end;

{---------------------------------------------------------------------------------
---------------}

Function Zona:Integer;
{Esta funcion pide el valor de la zona y verifica que este en el rango}
Var
Z : Integer;
R : Char;
Begin
Repeat
clrscr;
Writeln('Ingresar la zona a la que corresponde la
infracci�n:');
Z := Validar_Enteros(1);
While (Validar_Zona (Z) = False) do
Begin
clrscr;
Writeln('ERROR!. La zona no existe. Ingresar
nuevamente:');
Z := Validar_Enteros(1);
end;
Clrscr;
Writeln('La zona ingresada es : Zona ',z,'.');
Writeln;
Writeln('�Desea Cambiarla? (S/N)');
R := Validar_SN;
Until (R = 'N') or (R = 'n');
Zona := Z;
end;

{---------------------------------------------------------------------------------
------------------------}

Procedure Placa (Var L1,L2,L3:Char; Var Num:longint);


{Este procedure pide el valor de la placa y lo verifica, y ademas obliga a que no
sea el AAA 000}
{Este valor es utilizado para el espacio vacio al guardar una placa y no tiene
sentido}
Var
R:Char;
T:Boolean;
Begin
Repeat
clrscr;
T := True;
Writeln('Ingresar N� de Placa del vehiculo:');
Repeat
Clrscr;
Writeln('Primer letra:');
L1 := Validar_Caracter;
Clrscr;
Writeln('Segunda letra:');
L2 := Validar_Caracter;
Clrscr;
Writeln('Tercer letra:');
L3 := Validar_Caracter;
Clrscr;
Writeln('Ingresar los tres ultimos n�meros');
Num := Validar_Enteros(3);
If ((L1 = 'A') and (L2 = 'A') and (L3 = 'A') and (num =
000)) then
Begin
Clrscr;
Writeln('La placa ingresada no existe; Ingrese
nuevamente.');
readkey;
T:= False;
end
else
T := True;
Until T;
Clrscr;
Writeln('La placa ingresada: ',L1,L2,L3,' ',num,'.');
Writeln;
Writeln('�Desea Corregirla? (S/N)');
R := Validar_SN;
Until (R = 'n') or (R = 'N');
end;

{---------------------------------------------------------------------------------
--}

Procedure Multas (Var Matriz1:Reales; Matriz2:Entera;t:Integer);


{Este procedure calcula el valor de la multa para cada infraccion ingresada}
Var
Ex,Mult:Real;
Begin
Ex := Matriz1[t,1] - VLim;
Mult := Ex*UT_Km*UT_Peso;
Matriz1[t,2]:= Mult;
end;

{---------------------------------------------------------------------------------
---}

Procedure Multas_Cant (Var Cant1,Cant2,Cant3,Cant4:integer; Mat:Entera;


j:integer);
{Este procedure suma la cantidad de multas efectuadas por zona}
Begin
Case Mat[j,2] of
1 : Cant1 := Cant1 + 1;
2 : Cant2 := Cant2 + 1;
3 : Cant3 := Cant3 + 1;
4 : Cant4 := Cant4 + 1;
end;
end;

{---------------------------------------------------------------------------------
----------}

Procedure Multas_Zona (Var Suma1, Suma2, Suma3, Suma4:Real; Mat1:Reales;


Mat2:Entera; j:integer);
{Este procedure suma el monto de las multas por zona}
Begin
Case Mat2[j,2] of
1 : Suma1 := Suma1 + Mat1[j,2];
2 : Suma2 := Suma2 + Mat1[j,2];
3 : Suma3 := Suma3 + Mat1[j,2];
4 : Suma4 := Suma4 + Mat1[j,2];
end;
end;

{---------------------------------------------------------------------------------
----------------}

Procedure Fecha (fecha_act:longint;Var Fecha:Longint);


{Este procedure verifica si la fecha existe en un calendario comun y que no sea
mayor que la fecha actual}
{Todo esto lo guarda en un solo valor compuesto por AAAAMMDD}
var
R: Char;
A,M,D,D1,i : longint;
Begin
i := 0;
Repeat
If i <> 0 then ClrScr;
i := i + 1;
Writeln('A�o:');
A := Validar_Enteros(4);
While (A < (Amin div 10000)) or (A > (Fecha_Act div 10000)) do
Begin
Clrscr;
Writeln('El a�o esta fuera de rango; Ingresar
nuevamente:');
A := Validar_Enteros(4);
end;
clrscr;
Writeln('Ingresar n�mero del Mes:');
M := Validar_Enteros (2);
while ((((fecha_act mod 10000) div 100) < M) and (A = (fecha_act
div 10000))) or (M > 12) or (M = 0) do
begin
Clrscr;
Writeln('El mes esta fuera de rango; Ingresar
nuevamente:');
M := Validar_Enteros(2);
end;
Case M of
1,3,5,7,8,10,12: D1:= 31;
4,6,9,11: D1:= 30;
2: Begin
if ((A mod 4)=0) then
D1:=29
else
D1:=28;
end;
end;
clrscr;
Writeln('Ingresar D�a:');
D := Validar_Enteros(2);
while ((((fecha_act mod 10000) div 100) = M) and (A = (fecha_act
div 10000)) and (D > (Fecha_act mod 100))) or (D > D1) do
begin
Clrscr;
Writeln('El d�a est� fuera de rango; Ingresar
nuevamente:');
D := Validar_Enteros(2);
end;
Clrscr;
Writeln('La fecha ingresada es: ',D,'/',M,'/',A,'.');
Writeln;
Writeln('�Desea cambiarla? (S/N)');
R := Validar_SN;
Until (R = 'n') or (R = 'N');
Fecha := (A*10000)+(M*100)+D;
end;

{---------------------------------------------------------------------------------
------------}

Procedure Cargar_Datos_Prueba(Var Mat1:entera;Var Mat2:reales;Var


Mat3:Caracter);
Var
i,t:integer;
Begin
i := CantDatos(Mat1);
Mat1[i,1] := 123; Mat1[i,2] := 1; Mat1[i,3] := 19891013;
Mat2[i,1] := 124;
Mat3[i,1] := 'Q'; Mat3[i,2] := 'W'; Mat3[i,3] := 'E';
Mat1[i + 1,1] := 456; Mat1[i + 1,2] := 2; Mat1[i + 1,3] :=
19620226;
Mat2[i + 1,1] := 130.5;
Mat3[i + 1,1] := 'R'; Mat3[i + 1,2] := 'T'; Mat3[i + 1,3] := 'Y';
Mat1[i + 2,1] := 789; Mat1[i + 2,2] := 3; Mat1[i + 2,3] :=
19600902;
Mat2[i + 2,1] := 100;
Mat3[i + 2,1] := 'A'; Mat3[i + 2,2] := 'S'; Mat3[i + 2,3] := 'D';
Mat1[i + 3,1] := 101; Mat1[i + 3,2] := 1; Mat1[i + 3,3] :=
19920918;
Mat2[i + 3,1] := 180.6;
Mat3[i + 3,1] := 'F'; Mat3[i + 3,2] := 'G'; Mat3[i + 3,3] := 'H';
Mat1[i + 4,1] := 112; Mat1[i + 4,2] := 1; Mat1[i + 4,3] :=
19870827;
Mat2[i + 4,1] := 85.76;
Mat3[i + 4,1] := 'Z'; Mat3[i + 4,2] := 'X'; Mat3[i + 4,3] := 'C';
Mat1[i + 5,1] := 131; Mat1[i + 5,2] := 3; Mat1[i + 5,3] :=
19870919;
Mat2[i + 5,1] := 191.43;
Mat3[i + 5,1] := 'V'; Mat3[i + 5,2] := 'B'; Mat3[i + 5,3] := 'N';
Mat1[i + 6,1] := 415; Mat1[i + 6,2] := 4; Mat1[i + 6,3] :=
19300118;
Mat2[i + 6,1] := 80.6;
Mat3[i + 6,1] := 'N'; Mat3[i + 6,2] := 'H'; Mat3[i + 6,3] := 'Y';
Mat1[i + 7,1] := 534; Mat1[i + 7,2] := 4; Mat1[i + 7,3] :=
19450414;
Mat2[i + 7,1] := 117.45;
Mat3[i + 7,1] := 'M'; Mat3[i + 7,2] := 'J'; Mat3[i + 7,3] := 'U';
Mat1[i + 8,1] := 228; Mat1[i + 8,2] := 3; Mat1[i + 8,3] :=
19640713;
Mat2[i + 8,1] := 143.1;
Mat3[i + 8,1] := 'K'; Mat3[i + 8,2] := 'L'; Mat3[i + 8,3] := 'P';
Mat1[i + 9,1] := 765; Mat1[i + 9,2] := 2; Mat1[i + 9,3] :=
19370430;
Mat2[i + 9,1] := 108.87;
Mat3[i + 9,1] := 'J'; Mat3[i + 9,2] := 'J'; Mat3[i + 9,3] := 'M';
Mat1[i + 10,1] := 207; Mat1[i + 10,2] := 3; Mat1[i + 10,3] :=
19231121;
Mat2[i + 10,1] := 81.77;
Mat3[i + 10,1] := 'M'; Mat3[i + 10,2] := 'A'; Mat3[i + 10,3] :=
'Z';
Mat1[i + 11,1] := 956; Mat1[i + 11,2] := 2; Mat1[i + 11,3] :=
19740831;
Mat2[i + 11,1] := 142.5;
Mat3[i + 11,1] := 'A'; Mat3[i + 11,2] := 'C'; Mat3[i + 11,3] :=
'M';
Mat1[i + 12,1] := 746; Mat1[i + 12,2] := 4; Mat1[i + 12,3] :=
19740522;
Mat2[i + 12,1] := 167.4;
Mat3[i + 12,1] := 'C'; Mat3[i + 12,2] := 'M'; Mat3[i + 12,3] :=
'P';
Mat1[i + 13,1] := 532; Mat1[i + 13,2] := 1; Mat1[i + 13,3] :=
19840308;
Mat2[i + 13,1] := 177.8;
Mat3[i + 13,1] := 'M'; Mat3[i + 13,2] := 'J'; Mat3[i + 13,3] :=
'M';
Mat1[i + 14,1] := 002; Mat1[i + 14,2] := 1; Mat1[i + 14,3] :=
19930229;
Mat2[i + 14,1] := 111.1;
Mat3[i + 14,1] := 'O'; Mat3[i + 14,2] := 'P'; Mat3[i + 14,3] :=
'I';
Mat1[i + 15,1] := 168; Mat1[i + 15,2] := 2; Mat1[i + 15,3] :=
19121212;
Mat2[i + 15,1] := 168.9;
Mat3[i + 15,1] := 'L'; Mat3[i + 15,2] := 'O'; Mat3[i + 15,3] :=
'E';
Mat1[i + 16,1] := 456; Mat1[i + 16,2] := 3; Mat1[i + 16,3] :=
20090524;
Mat2[i + 16,1] := 289.0;
Mat3[i + 16,1] := 'R'; Mat3[i + 16,2] := 'I'; Mat3[i + 16,3] :=
'P';
Mat1[i + 17,1] := 910; Mat1[i + 17,2] := 2; Mat1[i + 17,3] :=
19300301;
Mat2[i + 17,1] := 147.5;
Mat3[i + 17,1] := 'A'; Mat3[i + 17,2] := 'T'; Mat3[i + 17,3] :=
'T';
Mat1[i + 18,1] := 335; Mat1[i + 18,2] := 4; Mat1[i + 18,3] :=
19590622;
Mat2[i + 18,1] := 91.3;
Mat3[i + 18,1] := 'P'; Mat3[i + 18,2] := 'E'; Mat3[i + 18,3] :=
'G';
Mat1[i + 19,1] := 456; Mat1[i + 19,2] := 4; Mat1[i + 19,3] :=
20080930;
Mat2[i + 19,1] := 144.5;
Mat3[i + 19,1] := 'R'; Mat3[i + 19,2] := 'T'; Mat3[i + 19,3] :=
'Y';
For t:= i to (i + 19) do
Multas (Mat2,Mat1,t);
end;

{---------------------------------------------------------------------------------
----------}

Procedure Multas_Periodo
(Mat1:reales;Mat2:entera;Fechainicial,Fechafinal:longint);
{Este procedure entrega el la cantidad de multas zonal, en un cierto periodo de
tiempo,}
{previamente especificado por el usuario}
Var
S1,S2,S3,S4 : Real;
C1,C2,C3,C4,i,N : Integer;
Begin
ClrScr;
S1:=0;S2:=0;S3:=0;S4:=0;
C1:=0;C2:=0;C3:=0;C4:=0;
N := CantDatos(Mat2) - 1;
For i := 1 to N do
Begin
If (Fechainicial <= Mat2[i,3]) and (Mat2[i,3] <=
Fechafinal) then
Begin
Multas_Cant(C1,C2,C3,C4,Mat2,i);
Multas_Zona(S1,S2,S3,S4,Mat1,Mat2,i);
end;
end;

Writeln('-----------------------------------------------------------------------')
;
Writeln('Para la Zona 1:':30);
If C1 = 0 then Writeln('NO HAY DATOS CARGADOS')
else
Begin
Writeln('Tot. de Infracciones: (En Pesos) ',
S1:35:3);
Writeln('Cantidad de Multas: ',
c1:35);
Writeln('Multa Promedio:
',(S1/C1):35:3);
end;
Writeln('-----------------------------------------------------------------------')
;
Writeln('Para la Zona 2:':30);
If C2 = 0 then Writeln('NO HAY DATOS CARGADOS')
else
Begin
Writeln('Tot. de Infracciones: (En Pesos) ',
S2:35:3);
Writeln('Cantidad de Multas: ',
c2:35);
Writeln('Multa Promedio:
',(S2/C2):35:3);
end;

Writeln('-----------------------------------------------------------------------')
;
Writeln('Para la Zona 3:':30);
If C3 = 0 then Writeln('NO HAY DATOS CARGADOS')
else
Begin
Writeln('Tot. de Infracciones: (En Pesos) ',
S3:35:3);
Writeln('Cantidad de Multas: ',
c3:35);
Writeln('Multa Promedio:
',(S3/C3):35:3);
end;

Writeln('-----------------------------------------------------------------------')
;
Writeln('Para la Zona 4:':30);
If C4 = 0 then Writeln('NO HAY DATOS CARGADOS')
else
Begin
Writeln('Tot. de Infracciones: (En Pesos) ',
S4:35:3);
Writeln('Cantidad de Multas: ',
c4:35);
Writeln('Multa Promedio:
',(S4/C4):35:3);
end;
end;

{---------------------------------------------------------------------------------
-------------}

Procedure Cargar_Matrices (Var Mat1:Entera; Var Mat2:Reales; Var


Mat3:caracter;F_Act:longint);
{Este procedure es la conjuncion de todos los procedure para validar u obtener
datos}
Var
R: Char;
i,t : Integer;
Begin
i := CantDatos(Mat1);
i := i - 1;
Writeln(i);
Repeat
i := i + 1;
clrscr;
Mat1[i,2] := Zona;
Mat2[i,1] := Vel;
Placa(Mat3[i,1],Mat3[i,2],Mat3[i,3],Mat1[i,1]);
Clrscr;
Writeln('Ingresar Fecha:');
Fecha(F_Act,Mat1[i,3]);
Multas (Mat2,Mat1,i);
clrscr;
Writeln('�Desea ingresar m�s datos? (S/N)');
R := Validar_SN;
Until (R = 'n') or (R = 'N');
end;

{---------------------------------------------------------------------------------
-------------}

Procedure Crear_Tabla (Anio:longint);


{Este procedure genera una "tabla" para ver el informe anual con todos los datos
pedidos}
Var
Linea, i, n, j : integer;
Begin
GotoXY (20,2);
Write ('Per�odo desde 01/01/',Anio:4,' al 31/12/',Anio:4);
For j := 1 to 3 do
Begin;
For n := 1 to 5 do
Begin
GotoXY ((20* j), 4 + n);
Write ('|');
End;
End;
For i := 0 to 1 do
Begin
GotoXY (1, 4+(i*6));
For linea := 1 to 79 do
Write ('-');
End;
GotoXY (6,6);
Write ('Placa del');
GotoXY (25,6);
Write ('Velocidad');
GotoXY (46,6);
Write ('Velocidad');
GotoXY (67,6);
Write ('Multa');
GotoXY (6,7);
Write ('Vehiculo');
GotoXY (25,7);
Write ('Registrada');
GotoXY (48,7);
Write ('Limite');
GotoXY (66,7);
Write ('(Pesos)');
GotoXY (27,8);
Write ('(Km/h)');
GotoXY (48,8);
Write ('(Km/h)');
End;

{---------------------------------------------------------------------------------
---------}

Procedure Crear_Lineas (Verticales : integer);


{Este procedure crea las "lineas verticales" de la tabla, guiandose de un dato
para que no quedan lineas mas}
{largas que la cantidad de datos}
var
lineas, j : integer;
Begin
For j := 1 to 3 do
Begin
For lineas := 1 to (2 * Verticales) do
Begin
GotoXY (j * 20, 10 + Lineas);
Write ('|');
End;
End;
End;

{---------------------------------------------------------------------------------
------------------}

Procedure Imprimir_Matriz (matrize: entera; matrizr: reales; matrizc: caracter;


anio_pedido: longint);
{Este procedure se encarga de imprimir la matriz ordenada en filas y columnas, de
una forma facil de leer}
{y pausando cada cierta cantidad de lineas}
var
Anioinicial, Aniofinal : longint;
N, j, i, k, C: integer;
Begin
Clrscr;
Anioinicial := Anio_Pedido * 10000;
Aniofinal := Anioinicial + 10000;
N := CantDatos (matrize)-1;
c := 0;
For i := 1 to N do
Begin
If (matrize [i,3] >= anioinicial) and (matrize [i,3] <=
aniofinal) then
Begin
c := c + 1;
GotoXY (7,10+(2*c));
For j := 1 to 3 do
write (matrizc [i,j]);
Write (' ');
If ((matrize[i,1] div 100) > 0) then
Write ((matrize [i,1]))
Else
Begin
If (matrize[i,1] div 10) > 0 then
Begin
Write ('0');
Write ((matrize [i,1])
Mod 100);
End
Else
Begin
Write ('00');
Write (matrize [i,1]
Mod 10);
End;
End;
GotoXY (28,10+(2*c));
Write (Matrizr [i,1] :5:2);
GotoXY (49,10+(2*c));
Write (Vlim);
GotoXY (66,10+(2*c));
Write (Matrizr [i,2] :7:2);
End;
k := 1;
If (c = 19*k) then
Begin
k := K + 1;
crear_lineas (19);
crear_tabla (Anio_Pedido);
readkey;
End;
End;
If c = 0 then
Begin
Writeln ('No hay ningun valor de multas en este
per�odo');
Readkey;
end
Else
Begin
If ((c mod 19) <> 0) then
Begin
crear_lineas ((c mod 19));
crear_tabla (Anio_Pedido);
readkey;
end;
End;
End;

{---------------------------------------------------------------------------------
----------}

Procedure Informe_Anual (Matriz1:entera; Matriz2:reales; Matriz3:caracter;


fecha_actual:longint);
{Este procedure junta los procedure de impresion de datos anuales, pide el valor
del periodo anual,y pregunta}
{como se desean ordenar los datos para ser mostrados}
var
p_anio,g: integer;
codigo: char;
Begin
Repeat
Clrscr;
Writeln ('Ingrese el a�o del cual desea obtener el informe');
p_anio := validar_enteros(4);
While (p_anio < (amin div 10000)) and (p_anio > (fecha_actual div
10000)) do
Begin
Clrscr;
Writeln ('Ingrese un a�o v�lido');
p_anio := validar_enteros(4);
End;
Clrscr;
Writeln('Desea ver los datos ordenados por:');
Writeln;
Writeln('1.-':30, 'Fecha.');
Writeln('2.-':30, 'Zona.');
Writeln('3.-':30, 'Valor de multa.');
Writeln;
Writeln('Elija una opci�n');
Repeat
g := Validar_Enteros(1);
until g in [1..3];
Case g of
1: Ordenar_Por_Fecha(Matriz1,Matriz2,Matriz3);
2: Ordenar_Por_Zona(Matriz1,Matriz2,Matriz3);
3: Ordenar_Por_Multa(Matriz1,Matriz2,Matriz3);
end;
Imprimir_Matriz (matriz1, matriz2, matriz3, p_anio);
Clrscr;
Writeln ('�Desea ingresar otro per�odo anual para analizar?
S/N');
Codigo := Validar_SN;
until (Codigo = 'N') or (Codigo = 'n');
End;

{---------------------------------------------------------------------------------
--------------}

Procedure Informe_Zonal_Periodo (Fecha_A:longint; Mat1:Entera; Mat2:Reales;


Mat3:Caracter);
{Este procedure pregunta el periodo de tiempo en el que se desea obtener el
informe zonal}
{En el caso de que el periodo este dise�ado para que el conjunto no contenga
ninguna fecha}
{el periodo es invertido automaticamente, para que tenga sentido la condicion de
periodo}
Var
R: Char;
Fechain,Fechafi: Longint;
Begin
Repeat
Clrscr;
Writeln('Ingeresar la fecha en la que se inicia el per�odo:');
Fecha(Fecha_A,Fechain);
Clrscr;
Writeln('Ingrese la fecha en que termina el per�odo:');
Fecha(Fecha_A,Fechafi);
If (Fechain > Fechafi) then
Invertir_Valores_enteros(Fechain,Fechafi);
clrscr;
Writeln('El per�odo ingresado es: Desde ',(Fechain mod
100),'/',((Fechain mod 10000) div 100),'/',(Fechain div 10000));
Writeln(' Hasta ',(Fechafi mod
100),'/',((Fechafi mod 10000) div 100),'/',(Fechafi div 10000));
Writeln;
Writeln('�Desea modificarlo? (S/N)');
R := Validar_SN;
Until (R = 'n') or (R = 'N');
Multas_Periodo(Mat2,Mat1,Fechain,Fechafi);
Writeln;
Writeln('Presione Enter para volver al menu':10);
Repeat
R := readkey
until (R = #13);
end;

{---------------------------------------------------------------------------------
-------------}

Procedure Menu (Var Mat1:Entera; Var Mat2:Reales; Var Mat3:caracter;


FechaAct:longint);
{Este procedure es el menu del programa, a partir del cual se puede llegar a todas
las opciones del mismo}
var
Opcion : integer;
Begin
clrscr;
Repeat
ClrScr;
Writeln('Menu':42);
Writeln;
Writeln('1.-':30, 'CARGAR DATOS');
Writeln('2.-':30, 'INFORME POR ZONA');
Writeln('3.-':30, 'INFORME ANUAL');
Writeln('4.-':30, 'SALIDA');
Writeln;
Writeln('0.-':30, 'DATOS PRUEBA');
Writeln('5.-':30, 'REINICIAR DATOS');
Repeat
GotoXY(2,23);
ClrEol;
Write('Introduzca la opci�n deseada');
Writeln;
Opcion := Validar_enteros(1);
Until Opcion in [0..5];
Case opcion of
1: Cargar_Matrices(Mat1,Mat2,Mat3,FechaAct);
2: Informe_Zonal_Periodo(FechaAct,Mat1,Mat2,Mat3);
3: Informe_Anual(Mat1, Mat2, Mat3, FechaAct);
0: Cargar_Datos_Prueba(Mat1, Mat2, Mat3);
5: Inicializacion (Mat1, Mat2, Mat3);
end;
Until (opcion = 4);
Clrscr;
Writeln('F I N D E P R O G R A M A':54);
readkey;
End;

{--------------------------------------------------------------------------------}

Procedure Fecha_Actual (Var F_a:longint);


{Este procedure pide la fecha actual, para ser usada despues y se fija que tenga
sentido en un calendario}
Var
R: Char;
Anio, Mes, Dia, D1:longint;
Begin
Repeat
clrscr;
Writeln('Ingrese la fecha actual:');
Writeln('A�o:');
Anio := Validar_Enteros(4);
While (Anio <= (Amin div 10000)) do
Begin
Clrscr;
Writeln('El a�o esta fuera de rango; Ingresar
nuevamente:');
Anio := Validar_Enteros(4);
end;
clrscr;
Writeln('Ingresar Mes:');
Mes := Validar_Enteros(2);
While (Mes > 12) or (Mes=0) do
Begin
Clrscr;
Writeln('Dicho mes no existe; Ingresar nuevamente:');
Mes := Validar_Enteros(2);
End;
Case Mes of
1,3,5,7,8,10,12: D1:= 31;
4,6,9,11: D1:= 30;
2: if ((Anio mod 4)=0) then D1:=29
else D1:=28;
end;
clrscr;
Writeln('Ingresar D�a:');
Dia := Validar_Enteros(2);
While (Dia > D1) do
Begin
Clrscr;
Writeln('El d�a est� fuera de rango; Ingresar
nuevamente:');
Dia := Validar_Enteros(2);
end;
Clrscr;
Writeln('La fecha ingresada es: ',Dia,'/',Mes,'/',Anio,'.');
Writeln;
Writeln('�Desea cambiarla? (S/N)');
R := Validar_SN;
Until (R = 'n') or (R = 'N');
F_A := (Anio*10000) + (Mes*100) + Dia;
end;

{---------------------------------------------------------------------------------
------------}

Procedure Inicio;
{Este procedure muetras el nombre de los integrantes del grupo y da la bienvenida
al programa}
Begin
Clrscr;
Writeln;
GotoXY(29,3);
Writeln('B I E N V E N I D O');
GotoXY(31,5);
Write('*** GRUPO 8 ***');
GotoXY(16,7);
Write('INTEGRANTES:');
GotoXY(18,10);
Write('Fainguerch Martin Alejandro - Padron : 90782');
GotoXY(18,12);
Write('Mart�nez Juan Marcos - Padron : 89139');
GotoXY(18,14);
Write('Mayra Daniela Goldman - Padron : 88439');
GotoXY(18,16);
Write('Mat�as Adri�n Alonso - Padron : 88152');
GotoXY(18,18);
Write('Maria Emilia Boyle - Padron : 89645');
GotoXY(45,21);
Writeln('PRESIONE UNA TECLA PARA CONTINUAR');
Readkey;
End;

{---------------------------------------------------------------------------------
----------}

Begin
Inicio;
Inicializacion (MEntera, MReal, MChar);
Fecha_Actual (F_Actual);
Menu(MEntera, MReal, MChar, F_Actual);
end.

----------------------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------------------------------------------
-----------------------------------------------------------------------
Program superproced;
Uses
crt;
Type Matriz=array [1..10,1..30] of real;
Vector=array [1..10] of real;
Vector1=array [1..10] of integer;
Vector2=array [1..1,1..30] of integer;
Var Mat:matriz; mon:real;
Const
fil=4;
col=6;
Procedure ceromatriz(var M:matriz{par�metro});
Var
I,J: integer;
Begin
I:=1;
For I:=1 to fil do
begin
J:=1;
for J:=1 to col do
M[I,J]:=0;
end;
end;
Procedure cargarmatriz(var M:matriz{par�metro});
Var
suc,caj: integer;mon: real;
Begin
Writeln ('Ingrese sucursal, caja y monto correspondiente');
Readln (suc,caj,mon);
While caj <> 0 do
begin
M[suc,caj]:=M[suc,caj]+mon;
Writeln ('Ingrese sucursal, caja y monto correspondiente');
Readln (suc,caj,mon);
end;
end;
Procedure prtmat(M:matriz{par�metro});
Var
I,J: integer;
Begin
I:=1;
For I:=1 to fil do
begin
J:=1;
for J:=1 to col do
write(' ',M[I,J]:4:2);
writeln('');
end;
end;
Procedure ordenarsuc(M:matriz{par�metro});
Var
I,J: integer;vecsum:vector;vec:vector1;aux:real;aux2:integer;
Begin
I:=1;
for I:=1 to fil do
vecsum[I]:=0;
I:=1;
For I:=1 to fil do
begin
vec[I]:=I;
J:=1;
for J:=1 to col do
vecsum[I]:=vecsum[I]+M[I,J];
end;
I:=1;
for I:=1 to fil-1 do
for J:=I+1 to fil do
If vecsum[I]<vecsum[J] then
begin
aux:=vecsum[I];
vecsum[I]:=vecsum[J];
vecsum[J]:=aux;
aux2:=vec[I];
vec[I]:=vec[J];
vec[J]:=aux2;
end;;
I:=1;
For I:=1 to fil do
Writeln('La sucursal ',vec[I],' recaud�: ',vecsum[I]:4:2)
end;
Procedure ordenarcaj(M:matriz{par�metro});
Var
I,J,K: integer;vec2:vector2;aux:real;aux2:integer;
Begin
J:=1;
For J:=1 to col do
vec2[1,J]:=J;
I:=1;
K:=1;
for K:=1 to fil do
begin
I:=1;
for I:=1 to col-1 do
for J:=I+1 to col do
If M[K,I]<M[K,J] then
begin
aux:=M[K,I];
M[K,I]:=M[K,J];
M[K,J]:=aux;
aux2:=vec2[1,I];
vec2[1,I]:=vec2[1,J];
vec2[1,J]:=aux2;
end;;
end;
I:=1;
For I:=1 to fil do
begin
J:=1;
Writeln('Sucursal ',I);
writeln('Cajas:');
for J:=1 to col do
write(' ',vec2[1,J]:2,' ');
writeln('');
J:=1;
for J:=1 to col do
write(' ',M[I,J]:4:1);
writeln('');
end;
end;
Function montomay (M:matriz):real;
Var
I,J,suc,caj: integer; mayor: real;
begin
mayor:=0;
I:=1;
for I:=1 to fil do
begin
J:=1;
for J:=1 to col do
if M[I,J]>mayor then
begin
mayor:=M[I,J];
suc:=I; caj:=J;
end;
end;
montomay:=mayor;
writeln ('La caja que m�s recaud� fue la n�mero ',caj,' de la sucursal
',suc)
end;
begin
clrscr;
ceromatriz(mat);{asignaci�n}
cargarmatriz(mat);
writeln('');
writeln ('Los datos matriciales son: ');
writeln('');
prtmat(mat);
writeln('');
ordenarsuc(mat);
writeln('');
ordenarcaj(mat);
writeln('');
mon:=montomay(mat);
writeln('Y el monto recaudado: $',mon:4:2);
readkey;
end.

----------------------------------------------------------------------------------
-----------------------------------------------------------------------
----------------------------------------------------------------------------------
-----------------------------------------------------------------------

Program elecciones;

{Trabajo pr�ctico grupo 19}


{Integrantes: Mignaqui, Gonzalo Padron : 91169 }
{ Medina, Julieta Padron : 9XXXX }
{ Ramirez, Francisco Padron : 9XXXX }
{Enunciado: Se pide leer una matriz.Los elementos de la misma son cantindad
de votos por partido para partidos de provincias. Son 22 provincias, a lo
sumo 30 partidos y 4 candidatos. Se pide:
1-Partido de provincia que m�s vot� al candidato 2.
2-Candidato ganador.
3-Porcentaje de cada candidato en el resultado total.}
{Fecha: 26/06/2009}
{Computaci�n-C�tedra Ing. Daniel Bur�n}
Uses
crt;

Const
Prov=22; Part=30; Cand=4;

Type Matriz=array [1..Prov,1..Part,1..Cand] of longint;


Vector=array [1..Cand] of longint;

Var Mat:matriz; {Matriz principal, aqui se cargaran los votos}

Procedure Ceromatriz(var M:matriz{par�metro});


Var
I,J,H: integer;
Begin
For I:=1 to Prov do
For J:=1 to Part do
For H:=1 to Cand do
M[I,J,H]:=0;

end;

Procedure Inicio;
{Este procedure muestra el nombre de los integrantes del grupo y da la bienvenida
al programa}
Begin
Clrscr;
Writeln;
GotoXY(29,3);
Writeln('B I E N V E N I D O');
GotoXY(31,5);
Write('*** GRUPO 8 ***');
GotoXY(16,7);
Write('INTEGRANTES:');
GotoXY(18,10);
GotoXY(18,12);
Write('Mignaqui, Gonzalo Padron : 91169');
GotoXY(18,14);
Write('Ramirez, Francisco Padron : 9XXXX');
GotoXY(18,16);
Write('Medina, Julieta Padron : 9XXXX');
GotoXY(35,21);
Writeln('PRESIONE UNA TECLA PARA CONTINUAR');
Readkey;
clrscr;
End;

Procedure Cargarmatriz(var M:matriz{par�metro});


{Este procedure permite cargar datos en la matriz}
Var
Pr,Pa,Ca: Integer;
Votos: Longint;
Begin
clrscr;
Writeln('Los datos se ingresan por campo por partido, especificando la
provincia.');
Writeln('');
Writeln('Recuerde ingresar "-1" como provincia para finalizar el ingreso
de datos');
Writeln('');
While Pr > -1 do
Begin
Write('Ingrese n�mero de Provincia: ');
Readln (Pr);
If Pr > -1 then {Control de ingreso de datos}
begin
Write('Ingrese n�mero de Partido: ');
Readln (Pa);
For Ca:=1 to cand do
begin
Write ('Ingrese los Votos al candidato
',Ca,': ');
Readln (Votos);
While Votos < 0 do {Control de ingreso de
datos}
Begin
write('Ingrese una cantidad de
votos positiva: ');
readln (votos);
end;
M[Pr,Pa,Ca]:= M[Pr,Pa,Ca] + Votos;
{Acumulador}
end;
end;
Writeln('');
end;
End;

Procedure Mayorvotos(M:matriz);
{Este procedure permite averiguar cual fue el partido donde mas votos obtuvo el
candidato a elegir}
Var
Pr,Pa,Ca,Provincia,Partido: integer; Mayor:longint;
Begin
clrscr;
Mayor:=0;
Write('Ingrese un candidato par averiguar el partido que mas lo vot�:
');
Readln(Ca);
writeln;
For Pr:=1 to prov do
For Pa:=1 to part do
If M[Pr,Pa,Ca] > Mayor then
begin
Mayor:= M[Pr,Pa,Ca];
Provincia:=Pr;
Partido:=Pa;
end;
Writeln('El partido ',Partido,' de la provincia ',Provincia,' fue el que
mas voto al candidato ',CA,'.');
Writeln;
Writeln('Obtuvo: ',Mayor,' votos');
End;

Procedure Ganador(M:matriz);
{Este procedure permite averiguar el ganador de las elecciones y calcular el
porcentaje de votos que obvtuvo cada uno}
Var
Pr,Pa,Ca,Gan: integer; Vectot:vector;
Porcentaje:real; Totalvot,Mayor:Longint;
Begin
Totalvot:=0;Mayor:=0;
For Ca:=1 to cand do {Inicializa la matriz}
Vectot[Ca]:=0;
For Pr:=1 to Prov do
For Pa:=1 to Part do
For Ca:=1 to Cand do
Begin
Vectot[Ca]:= Vectot[CA] + M[Pr,Pa,Ca];
Totalvot:= Totalvot + M[Pr,Pa,Ca];
end;;;
For Ca:=1 to Cand do
If Vectot[Ca] > Mayor then
Begin;
Mayor:= Vectot[Ca];
Gan:= Ca;
End;
Writeln('El ganador fue el candidato ',Gan,' obteniendo ',Mayor,'
votos.');
Writeln('');
Writeln('El total de votos emitidos fue: ',Totalvot,' votos.');
Writeln('');
For Ca:=1 to Cand do
Begin
if totalvot > 0 then
Begin
Porcentaje:= Vectot[CA]/Totalvot*100; {Calcula el
porcentaje}
Writeln('El porcentaje de votos que obtuvo el candidato
',Ca,' fue un ',Porcentaje:2:2,'% del total.');
end;
End;
Writeln;
Writeln('Presione una tecla para regresar al men�');
Readkey;
End;

Procedure Menu (Var Mat1:Matriz);


{Este procedure es el menu del programa, a partir del cual se puede llegar a todas
las opciones del mismo}
var
Opcion : integer;
Begin
clrscr;
Repeat
ClrScr;
GoToXY(30,7);
Writeln('Menu');
Writeln;
Writeln('1.-':30, 'CARGAR DATOS DE LA ELECCI�N');
Writeln;
Writeln('2.-':30, 'VER RESULTADOS');
Writeln;
Writeln('3.-':30, 'SALIDA');
Repeat
GotoXY(2,23);
ClrEol;
Write('Introduzca la opci�n deseada: ');
Readln(opcion);
Until Opcion in [0..3];
Case opcion of
1: Begin
ceromatriz(mat);
cargarmatriz(mat);
End;
2: Begin
Mayorvotos(mat);
writeln('');
Ganador(mat);
writeln('');
End;
end;
Until (opcion = 3);
Clrscr;
GoToXY(15,14);
Write('********** F I N D E P R O G R A M A **********');
readkey;
End;

{************** Se Inicia el Programa Principal ****************}

Begin
clrscr;
Inicio; {Procedimiento de inicio del programa}
Menu(mat); {Procedimiento que situa al usuario en el menu}
end.

----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
--------------------------------------------------------------------

program supermercado;
uses

crt;
const
S=4; C=5;
type
vector= array [1..S,1..C] of real;
var
recaud: vector; aux,monto:real; H,caj,suc,I,J:integer;
begin
clrscr;
I:=1 ; J:=1;
for I:= 1 to S do {rellenado}
begin
J:=1;
for J:= 1 to C do
recaud[I,J]:=0;
end;
I:=2 ; J:=2;aux:=0;monto:=0;
for I:= 2 to S do {indexado}
recaud[I,1]:=I-1;
for J:= 2 to C do {indexado}
recaud[1,J]:=J-1;
Writeln('Presione enter para comenzar, sepa que para finalizar debe
introducir un n�mero nulo como sucursal.');
readkey;
clrscr;
Write('Ingrese sucursal: ');
Readln(suc);
while suc > 0 do
begin
Write('Ingrese numero de caja: ');
Readln(caj);
Write('Ingrese monto: ');
readln(monto);
recaud[(suc+1),(caj+1)]:=recaud[(suc+1),(caj+1)]+monto;
clrscr;
Write('Ingrese sucursal: ');
Readln(suc);
end;
clrscr;
write('Ingrese sucursal para ordenar la tabla de recaudaciones: ');
readln(caj);
writeln('Recaudaci�n ordenada de mayor a menor seg�n cajas de la sucursal:
',caj);
writeln('');
{fila: suc+1, columna: va de 2 a C-1, se cambia entera}
I:=2;H:=2;
for I:=2 to C-1 do
begin
J:=I+1;
for J:=I+1 to C do
if recaud[suc+1,I]>recaud[suc+1,J] then
else
for H:=1 to S do
begin
aux:=recaud[H,J];
recaud[H,I]:=recaud[H,J];
recaud[H,I]:=aux;
end;;
H:=2;
end;
I:=1; J:=1;
writeln('');
for I:=1 to S do
begin
for J:=1 to C do
begin
write(' ',recaud [I,J]:2:1,' ');
end;
J:=1;
writeln('');
end;
readkey;
clrscr;
write('Ingrese caja para ordenar la tabla de recaudaciones: ');
readln(caj);
writeln('Recaudaci�n ordenada de mayor a menor seg�n caja: ',caj);
writeln('');
{columna fija: caj,fila: va de 2 hasta S-1, se cambia entera}
I:=2;H:=2;
for I:=2 to S-1 do
begin
J:=I+1;
for J:=I+1 to S do
if recaud[I,caj+1]>recaud[J,caj+1] then
else
for H:=1 to C do
begin
aux:=recaud[I,H];
recaud[I,H]:=recaud[J,H];
recaud[J,H]:=aux;
end;;
H:=2;
end;
I:=2;
for I:=2 to C-1 do
begin
J:=I+1;
for J:=I+1 to C do
if recaud[suc+1,I]>recaud[suc+1,J] then
else
begin
aux:=recaud[suc+1,I];
recaud[suc+1,I]:=recaud[suc+1,J];
recaud[suc+1,J]:= aux;
end;;
end;
I:=1; J:=1;
writeln('');
for I:=1 to S do
begin
for J:=1 to C do
begin
write(' ',recaud [I,J]:2:1,' ');
end;
J:=1;
writeln('');
end;
readkey;
end.

----------------------------------------------------------------------------------
---------------------------------------------------------------------------
----------------------------------------------------------------------------------
---------------------------------------------------------------------------
program euclides;
uses
crt;
var
a,b,r,out:integer;
begin
out:=1;
while out <> 0 do
begin
clrscr;
writeln ('ingrese un n�mero y presione enter');
readln (a);
writeln ('ingrese otro n�mero y presione enter');
readln (b);
If a <> b then
begin
if a > b then
begin
r:= a mod b ;
while r <> 0 do
begin
a:=b ;
b:=r ;
r:= a mod b ;
end;
Writeln (b, ' es el m�ximo com�n divisor');
end
else
begin
r:= b mod a ;
while r <> 0 do
begin
b:=a ;
a:=r ;
r:= b mod a ;
end;
Writeln (a, ' es el minimo comun multiplo');
end;
end
else
writeln (a, ' es el minimo comun multiplo');
writeln ('ingrese "0" para finalizar o algun otro numero para seguir y presione
enter');
readln(out);
end;
end.

----------------------------------------------------------------------------------
---------------------------------------------------------------------------
----------------------------------------------------------------------------------
---------------------------------------------------------------------------

Program archivos;

Uses crt;

Var
caract:char;
filein, fileout: text;

Begin
assign(filein,'c:\filein.txt');
assign(fileout,'c:\fileout.txt');
reset(filein);
rewrite(fileout);
read(filein,caract);
write(fileout,caract);
close(filein);
close(fileout);
Readkey
end.

Você também pode gostar