Escolar Documentos
Profissional Documentos
Cultura Documentos
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}
{------------------------------------------------------------------------------}
{---------------------------------------------------------------------------------
}
{---------------------------------------------------------------------------------
}
{---------------------------------------------------------------------------------
}
{-------------------------------------------------------------------------------}
{---------------------------------------------------------------------------------
------------------}
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;
{---------------------------------------------------------------------------------
------------------}
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;
{---------------------------------------------------------------------------------
------------------}
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 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 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 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;
Const
Prov=22; Part=30; Cand=4;
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 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;
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.