Error actualizado!!!
Publicado por J (83 intervenciones) el 28/10/2007 21:17:14
soy el del post del runtime de mas abajo, la cosa es que pude solucionar muchos delos problemas pero hay errores todavia, miren aca esta el codigo para crear el archivo accidentes
Con este creo uno de los dos archivos:
Program crearchaccidentes;
Type
Str4=string[4];
Str5=string[5];
RAcc=record
CodEmp:str4;
Leg:str5;
Fecha:Longint;
CantDiasLic:word
end;
AAcc=File of RAcc;
Var
ArchAcc:AAcc;
RegAcc:RAcc;
i:byte;
respuesta:char;
Begin
assign(ArchAcc,'Accidentes.dat');
rewrite(ArchAcc);
repeat
writeln('Ingrese c¢digo de la empresa(4 caracteres)');
readln(RegAcc.CodEmp);
writeln('Ingrese n£mero de legajo(5 caracteres)');
readln(RegAcc.leg);
writeln('Ingrese la fecha(6 digitos)');
readln(RegAcc.fecha);
writeln('Ingrese la cantidad de d¡as de licencia(3 d¡gitos)');
readln(RegAcc.CantDiasLic);
write(ArchAcc,RegAcc);
writeln('¨Desea agregar otro registro?(S o N)');
readln(respuesta)
until respuesta='N';
close(ArchAcc)
end.
con este creo otro:
Program crearchempre;
Type
Str4=string[4];
Str40=string[40];
REmp=record
CodEmp:str4;
RazSoc:str40;
CanTraAs:word
end;
AEmp=File of REmp;
Var
ArchEmp:AEmp;
RegEmp:REmp;
i:byte;
Begin
assign(ArchEmp,'Empresas.dat');
rewrite(ArchEmp);
for i:=1 to 3 do
begin
writeln('Ingrese c¢digo de la empresa(4 caracteres)');
readln(RegEmp.CodEmp);
writeln('Ingrese raz¢n social(40 caracteres)');
readln(RegEmp.RazSoc);
writeln('Ingrese Cantidad de trabajadores asegurados(3 digitos)');
readln(RegEmp.CanTraAs);
write(ArchEmp,RegEmp)
end;
close(ArchEmp)
end.
y por ultimo el programa que gestiona los otros dos archivos para sacar dos listados es este, el cual tiene un problema en el modulo procesar creo yo, no estoy seguro aca esta el codigo:
Program TrabajoPractico;
Uses crt,dos;
Type
Str5=string[5];
Str4=string[4];
Str40=string[40];
REmp=record
CodEmp:str4;
RazSoc:str40;
CanTrabAs:word
end;
RAcc=record
CodEmp:str4;
Leg:str5;
Fecha:Longint;
CantDiasLic:word
end;
AEmp=File of REmp;
AAcc=File of RAcc;
RegVemp=record
Codemp:str4;
Razsoc:str40;
CanTrabAs:word;
Porc:byte
end;
TipoInfo=record
Leg:Str5;
CantDiasLic:byte
end;
Tipolista=^tiponodo;
Tiponodo=record
Info:TipoInfo;
Sgte:TipoLista
end;
TvecEmp=Array[1..3] of RegVemp;
TveCont=Array[1..3] of Word;
TvecLis=array[1..3] of TipoLista;
(*Desarrollo de Procedimientos*)
Procedure Abrir(var Empresas:AEmp;Var Accidentes:AAcc);
Begin
assign(Empresas,'Empresas.Dat');
Reset(Empresas);
assign(Accidentes,'Accidentes.Dat');
Reset(Accidentes)
end;
Procedure Inicializar(Var ContAcc:TVeCont;Var Veclis:TvecLis);
Var i:byte;
Begin
for i:=1 to 3 do
begin
ContAcc[i]:=0;
VecLis[i]:=nil
end
end;
Procedure Cargar_Vector(var Empresas:AEmp;Var VecEmp:TvecEmp);
Var i:byte;
Rempresas:Remp;
Begin
For i:=1 to 3 do
begin
read(Empresas,Rempresas);
VecEmp[i].CodEmp:=Rempresas.Codemp;
VecEmp[i].RazSoc:=Rempresas.Razsoc;
VecEmp[i].CanTrabAs:=Rempresas.CanTrabAs
end
end;
Procedure Leer(var Accidentes:AAcc;var RegAcc:RAcc;Var FinArch:boolean);
Begin
if not eof(Accidentes) then
begin
read(Accidentes,RegAcc);
FinArch:=false
end
else
FinArch:=true
end;
Procedure Bus_Lin_Vec(VecEmp:TvecEmp;cod:str4;var pos:word);
Var encontrado:boolean;
i:byte;
Begin
i:=1;
encontrado:=false;
while not (encontrado) do
begin
if VecEmp[i].CodEmp=cod then
begin
encontrado:=true;
pos:=i
end;
inc(i)
end
end;
Function Porcen(CantrabAs,cont:word):byte;
begin
Porcen:=random(100)
end;
Procedure Inserta_Primero(var lista:tipolista;valor:tipoinfo);
var Ptr:TipoLista;
Begin
new(Ptr);
Ptr^.Info:=valor;
Ptr^.sgte:=nil;
lista:=Ptr
end;
Procedure Inserta_Delante(Var Lista:TipoLista;Info:TipoInfo);
var Ptr:Tipolista;
Begin
New(Ptr);
Ptr^.Info:=Info;
Ptr^.Sgte:=lista;
Lista:=Ptr
end;
Procedure Inserta_En_Medio(var Lista:tipoLista;Info:TipoInfo);
Var Ptr,PtrNuevo:tipolista;
Begin
new(PtrNuevo);
PtrNuevo^.Info:=Info;
PtrNuevo^.sgte:=nil;
Ptr:=Lista;
while ((ptr^.sgte<>nil) and (info.CantDiasLic>Ptr^.sgte^.info.CantDiasLic)) do
ptr:=ptr^.sgte;
PtrNuevo^.sgte:=Ptr^.sgte;
Ptr^.sgte:=PtrNuevo
end;
Procedure Agregar_Nodo_Lista(var lista:tipolista; Info:TipoInfo);
Begin
If lista= nil then
Inserta_Primero(Lista,Info)
else
begin
if info.CantDiasLic<Lista^.Info.CantDiasLic then
inserta_Delante(Lista,Info)
else
inserta_En_Medio(Lista,Info)
end
end;
Procedure Procesar(Var Accidentes:AAcc;Var VecEmp:TVecEmp;Var VContAcc:Tvecont;Var VecLIsEmp:TVecLis);
var i,DiasLic:byte;
clave:str5;
RInfo:TipoInfo;
RegAcc:Racc;
Pos:Word;
FinArch:boolean;
Begin
Leer(Accidentes,Regacc,FinArch);
while not FinArch do
begin
clave:=Regacc.Leg;
Rinfo.Leg:=Regacc.leg;
DiasLic:=0;
while (not FinArch) and (Regacc.Leg=clave) do
begin
DiasLic:=DiasLic+Regacc.CantDiasLic;
Leer(Accidentes,Regacc,FinArch);
end;
Bus_Lin_Vec(VecEmp,Regacc.CodEmp,Pos);
VContAcc[Pos]:=VContAcc[Pos]+1;
Rinfo.CantDiasLic:=DiasLic;
Agregar_Nodo_Lista(VecLisEmp[Pos],Rinfo)
end;
for i:=1 to 3 do
VecEmp[i].Porc:=Porcen(VecEmp[i].CanTrabAs,VContAcc[i])
end;
Procedure OrdenarMam(var VecEmp:TVecEmp;var VeclisEmp:TVecLis;Tope:byte);
var ordenado:boolean;
aux:RegVemp;
AuxLis:TipoLista;
i:byte;
Begin
Ordenado:=false;
while not ordenado do
begin
Ordenado:=True;
for i:=1 to tope-1 do
begin
if VecEmp[i].Porc<VecEmp[i+1].Porc then
begin
Aux:=VecEmp[i];
VecEmp[i]:=VecEmp[i+1];
VecEmp[i+1]:=Aux;
AuxLis:=VecLisEmp[i];
VecLisEmp[i]:=VecLisEmp[i+1];
VecLisEmp[i+1]:=AuxLis;
Ordenado:=False
end
end
end
end;
Procedure ListarPorc(VecEmp:TvecEmp);
Var i:byte;
Begin
for i:=1 to 3 do
begin
writeln('Empresa: ',VecEmp[i].RazSoc);
writeln('Porcentaje: ',VecEmp[i].Porc)
end
end;
Procedure Suprime_Nodo_Lista(var Lista:TipoLista;Var Info:TipoInfo);
Var PtrAct,PtrAnt:TipoLista;
Begin
PtrAct:=Lista;
PtrAnt:=Nil;
while (PtrAct<>Nil) and (Info.CantDiasLic>PtrAct^.Info.CantDiasLic) do
begin
PtrAnt:=PtrAct;
PtrAct:=PtrAct^.Sgte
end;
If (PtrAct<>Nil) and (Info.CantDiasLic=PtrAct^.Info.CantDiasLic) then
begin
if PtrAnt<>Nil then
PtrAnt^.Sgte:=PtrAct^.sgte
else
Lista:=PtrAct^.Sgte
end;
dispose(PtrAct)
end;
Procedure ListarTrabAcc(VecEmp:TVecEmp;VecLis:TVecLis);
Var Rinfo:TipoInfo;
Begin
writeln;
writeln;
writeln('Empresas: ',VecEmp[1].RazSoc);
writeln;
writeln('Legajo del Trabajador Cantidad de Inasistencias');
while Veclis[1]<> Nil do
begin
Suprime_Nodo_Lista(VecLis[1],RInfo);
writeln(RInfo.Leg,' ',Rinfo.CantDiasLic)
end
end;
(*Variables Globales*)
Var
Empresas:AEmp;
Accidentes:AAcc;
Veclis:Tveclis;
CantAcc:TVeCont;
VecEmp:TVecEmp;
(*Bloque Principal*)
Begin
Abrir(Empresas,Accidentes);
Inicializar(CantAcc,VecLis);
Cargar_Vector(Empresas,VecEmp);
Procesar(Accidentes,VecEmp,CantAcc,VecLis);
OrdenarMam(VecEmp,VecLis,3);
ListarPorc(VecEmp);
ListarTrabAcc(VecEmp,VecLis);
Close(Empresas);
Close(Accidentes);
readkey
end.
si me pueden decir que esta mal( sospecho que tiene algo qeu ver con los punteros) se los agradecería saludos
Con este creo uno de los dos archivos:
Program crearchaccidentes;
Type
Str4=string[4];
Str5=string[5];
RAcc=record
CodEmp:str4;
Leg:str5;
Fecha:Longint;
CantDiasLic:word
end;
AAcc=File of RAcc;
Var
ArchAcc:AAcc;
RegAcc:RAcc;
i:byte;
respuesta:char;
Begin
assign(ArchAcc,'Accidentes.dat');
rewrite(ArchAcc);
repeat
writeln('Ingrese c¢digo de la empresa(4 caracteres)');
readln(RegAcc.CodEmp);
writeln('Ingrese n£mero de legajo(5 caracteres)');
readln(RegAcc.leg);
writeln('Ingrese la fecha(6 digitos)');
readln(RegAcc.fecha);
writeln('Ingrese la cantidad de d¡as de licencia(3 d¡gitos)');
readln(RegAcc.CantDiasLic);
write(ArchAcc,RegAcc);
writeln('¨Desea agregar otro registro?(S o N)');
readln(respuesta)
until respuesta='N';
close(ArchAcc)
end.
con este creo otro:
Program crearchempre;
Type
Str4=string[4];
Str40=string[40];
REmp=record
CodEmp:str4;
RazSoc:str40;
CanTraAs:word
end;
AEmp=File of REmp;
Var
ArchEmp:AEmp;
RegEmp:REmp;
i:byte;
Begin
assign(ArchEmp,'Empresas.dat');
rewrite(ArchEmp);
for i:=1 to 3 do
begin
writeln('Ingrese c¢digo de la empresa(4 caracteres)');
readln(RegEmp.CodEmp);
writeln('Ingrese raz¢n social(40 caracteres)');
readln(RegEmp.RazSoc);
writeln('Ingrese Cantidad de trabajadores asegurados(3 digitos)');
readln(RegEmp.CanTraAs);
write(ArchEmp,RegEmp)
end;
close(ArchEmp)
end.
y por ultimo el programa que gestiona los otros dos archivos para sacar dos listados es este, el cual tiene un problema en el modulo procesar creo yo, no estoy seguro aca esta el codigo:
Program TrabajoPractico;
Uses crt,dos;
Type
Str5=string[5];
Str4=string[4];
Str40=string[40];
REmp=record
CodEmp:str4;
RazSoc:str40;
CanTrabAs:word
end;
RAcc=record
CodEmp:str4;
Leg:str5;
Fecha:Longint;
CantDiasLic:word
end;
AEmp=File of REmp;
AAcc=File of RAcc;
RegVemp=record
Codemp:str4;
Razsoc:str40;
CanTrabAs:word;
Porc:byte
end;
TipoInfo=record
Leg:Str5;
CantDiasLic:byte
end;
Tipolista=^tiponodo;
Tiponodo=record
Info:TipoInfo;
Sgte:TipoLista
end;
TvecEmp=Array[1..3] of RegVemp;
TveCont=Array[1..3] of Word;
TvecLis=array[1..3] of TipoLista;
(*Desarrollo de Procedimientos*)
Procedure Abrir(var Empresas:AEmp;Var Accidentes:AAcc);
Begin
assign(Empresas,'Empresas.Dat');
Reset(Empresas);
assign(Accidentes,'Accidentes.Dat');
Reset(Accidentes)
end;
Procedure Inicializar(Var ContAcc:TVeCont;Var Veclis:TvecLis);
Var i:byte;
Begin
for i:=1 to 3 do
begin
ContAcc[i]:=0;
VecLis[i]:=nil
end
end;
Procedure Cargar_Vector(var Empresas:AEmp;Var VecEmp:TvecEmp);
Var i:byte;
Rempresas:Remp;
Begin
For i:=1 to 3 do
begin
read(Empresas,Rempresas);
VecEmp[i].CodEmp:=Rempresas.Codemp;
VecEmp[i].RazSoc:=Rempresas.Razsoc;
VecEmp[i].CanTrabAs:=Rempresas.CanTrabAs
end
end;
Procedure Leer(var Accidentes:AAcc;var RegAcc:RAcc;Var FinArch:boolean);
Begin
if not eof(Accidentes) then
begin
read(Accidentes,RegAcc);
FinArch:=false
end
else
FinArch:=true
end;
Procedure Bus_Lin_Vec(VecEmp:TvecEmp;cod:str4;var pos:word);
Var encontrado:boolean;
i:byte;
Begin
i:=1;
encontrado:=false;
while not (encontrado) do
begin
if VecEmp[i].CodEmp=cod then
begin
encontrado:=true;
pos:=i
end;
inc(i)
end
end;
Function Porcen(CantrabAs,cont:word):byte;
begin
Porcen:=random(100)
end;
Procedure Inserta_Primero(var lista:tipolista;valor:tipoinfo);
var Ptr:TipoLista;
Begin
new(Ptr);
Ptr^.Info:=valor;
Ptr^.sgte:=nil;
lista:=Ptr
end;
Procedure Inserta_Delante(Var Lista:TipoLista;Info:TipoInfo);
var Ptr:Tipolista;
Begin
New(Ptr);
Ptr^.Info:=Info;
Ptr^.Sgte:=lista;
Lista:=Ptr
end;
Procedure Inserta_En_Medio(var Lista:tipoLista;Info:TipoInfo);
Var Ptr,PtrNuevo:tipolista;
Begin
new(PtrNuevo);
PtrNuevo^.Info:=Info;
PtrNuevo^.sgte:=nil;
Ptr:=Lista;
while ((ptr^.sgte<>nil) and (info.CantDiasLic>Ptr^.sgte^.info.CantDiasLic)) do
ptr:=ptr^.sgte;
PtrNuevo^.sgte:=Ptr^.sgte;
Ptr^.sgte:=PtrNuevo
end;
Procedure Agregar_Nodo_Lista(var lista:tipolista; Info:TipoInfo);
Begin
If lista= nil then
Inserta_Primero(Lista,Info)
else
begin
if info.CantDiasLic<Lista^.Info.CantDiasLic then
inserta_Delante(Lista,Info)
else
inserta_En_Medio(Lista,Info)
end
end;
Procedure Procesar(Var Accidentes:AAcc;Var VecEmp:TVecEmp;Var VContAcc:Tvecont;Var VecLIsEmp:TVecLis);
var i,DiasLic:byte;
clave:str5;
RInfo:TipoInfo;
RegAcc:Racc;
Pos:Word;
FinArch:boolean;
Begin
Leer(Accidentes,Regacc,FinArch);
while not FinArch do
begin
clave:=Regacc.Leg;
Rinfo.Leg:=Regacc.leg;
DiasLic:=0;
while (not FinArch) and (Regacc.Leg=clave) do
begin
DiasLic:=DiasLic+Regacc.CantDiasLic;
Leer(Accidentes,Regacc,FinArch);
end;
Bus_Lin_Vec(VecEmp,Regacc.CodEmp,Pos);
VContAcc[Pos]:=VContAcc[Pos]+1;
Rinfo.CantDiasLic:=DiasLic;
Agregar_Nodo_Lista(VecLisEmp[Pos],Rinfo)
end;
for i:=1 to 3 do
VecEmp[i].Porc:=Porcen(VecEmp[i].CanTrabAs,VContAcc[i])
end;
Procedure OrdenarMam(var VecEmp:TVecEmp;var VeclisEmp:TVecLis;Tope:byte);
var ordenado:boolean;
aux:RegVemp;
AuxLis:TipoLista;
i:byte;
Begin
Ordenado:=false;
while not ordenado do
begin
Ordenado:=True;
for i:=1 to tope-1 do
begin
if VecEmp[i].Porc<VecEmp[i+1].Porc then
begin
Aux:=VecEmp[i];
VecEmp[i]:=VecEmp[i+1];
VecEmp[i+1]:=Aux;
AuxLis:=VecLisEmp[i];
VecLisEmp[i]:=VecLisEmp[i+1];
VecLisEmp[i+1]:=AuxLis;
Ordenado:=False
end
end
end
end;
Procedure ListarPorc(VecEmp:TvecEmp);
Var i:byte;
Begin
for i:=1 to 3 do
begin
writeln('Empresa: ',VecEmp[i].RazSoc);
writeln('Porcentaje: ',VecEmp[i].Porc)
end
end;
Procedure Suprime_Nodo_Lista(var Lista:TipoLista;Var Info:TipoInfo);
Var PtrAct,PtrAnt:TipoLista;
Begin
PtrAct:=Lista;
PtrAnt:=Nil;
while (PtrAct<>Nil) and (Info.CantDiasLic>PtrAct^.Info.CantDiasLic) do
begin
PtrAnt:=PtrAct;
PtrAct:=PtrAct^.Sgte
end;
If (PtrAct<>Nil) and (Info.CantDiasLic=PtrAct^.Info.CantDiasLic) then
begin
if PtrAnt<>Nil then
PtrAnt^.Sgte:=PtrAct^.sgte
else
Lista:=PtrAct^.Sgte
end;
dispose(PtrAct)
end;
Procedure ListarTrabAcc(VecEmp:TVecEmp;VecLis:TVecLis);
Var Rinfo:TipoInfo;
Begin
writeln;
writeln;
writeln('Empresas: ',VecEmp[1].RazSoc);
writeln;
writeln('Legajo del Trabajador Cantidad de Inasistencias');
while Veclis[1]<> Nil do
begin
Suprime_Nodo_Lista(VecLis[1],RInfo);
writeln(RInfo.Leg,' ',Rinfo.CantDiasLic)
end
end;
(*Variables Globales*)
Var
Empresas:AEmp;
Accidentes:AAcc;
Veclis:Tveclis;
CantAcc:TVeCont;
VecEmp:TVecEmp;
(*Bloque Principal*)
Begin
Abrir(Empresas,Accidentes);
Inicializar(CantAcc,VecLis);
Cargar_Vector(Empresas,VecEmp);
Procesar(Accidentes,VecEmp,CantAcc,VecLis);
OrdenarMam(VecEmp,VecLis,3);
ListarPorc(VecEmp);
ListarTrabAcc(VecEmp,VecLis);
Close(Empresas);
Close(Accidentes);
readkey
end.
si me pueden decir que esta mal( sospecho que tiene algo qeu ver con los punteros) se los agradecería saludos
Valora esta pregunta


0