Skip to content

Instantly share code, notes, and snippets.

@matipan
Created May 27, 2017 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matipan/aaf1563ebca5bf774cb7836c3eeae253 to your computer and use it in GitHub Desktop.
Save matipan/aaf1563ebca5bf774cb7836c3eeae253 to your computer and use it in GitHub Desktop.
program ejercicio2;
const
valoralto = 9999;
type
viajeTipo = record
codViaje: integer;
nombre: string[20];
desc: string[100];
precio: real;
cantPasajes: integer;
end;
ventaTipo = record
codViaje: integer;
cantPasajes: integer;
end;
armaestro = file of viajeTipo;
ardetalle = file of ventaTipo;
procedure leerViaje(var maestro: armaestro; var viaje: viajeTipo);
begin
if(not EOF(maestro)) then
read(maestro, viaje);
else
viaje.codViaje = valoralto;
end;
procedure leerVenta(var maestro: armaestro; var viaje: viajeTipo);
begin
end;
var
viaje: viajeTipo;
venta: ventaTipo;
maestro: armaestro;
detalle: ardetalle;
texto: text;
begin
assign(maestro, 'maestroejer2'); assign(detalle, 'detallejer2');
reset(maestro); reset(detalle);
{estan ordenados por codigo de viaje el detalle y maestro}
leerViaje(maetro, viaje); leerVenta(detalle, venta);
while((viaje.codViaje <> valoralto) and (venta.codViaje <> valoralto)) do
begin
while(venta.codViaje = viaje.codViaje) do
begin
viaje.cantPasajes = viaje.cantPasajes + venta.cantPasajes;
leerVenta(detalle, venta);
end;
seek(maestro, filepos(maestro)-1);
write(maestro, viaje);
leerViaje(maestro, viaje);
end;
close(maestro);
assign(texto, 'ventas.txt');
rewrite(texto); reset(maestro);
leerViaje(maestro, viaje);
while(viaje.codViaje <> valoralto) do
begin
if viaje.cantPasajes > 0 then
begin
write(texto, viaje.nombre); write(texto, ' ');
write(texto, viaje.desc); write(texto, ' ');
write(texto, viaje.precio); write(texto, ' ');
writeln(texto, viaje.cantPasajes);
end;
leerViaje(maestro, viaje);
end;
close(maestro);
close(detalle);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment