N . N . :
1. .
2. .
3. .
4. .
, . .
, , , , , . , , , . . .
, N=10, M=3.
Program dom9;
type zap=record
name: string;
cost: integer;
date: 1900..2222;
quantity: integer;
end;
fpk=file of zap;
var fizap,rb:fpk; s1,a,b:zap; i,j:integer;
procedure PrintFile(fizap:fpk);
var a:zap; i:integer; s:string;
begin
i:=1;
reset(fizap);
repeat
read(fizap,a);
writeln(i:2,' : ',a.name,', : ', a.cost, ', : ',a.date,', -: ',a.quantity);
i:=i+1;
until eof(fizap);
close(fizap);
end;
procedure InSortfile(var f: file of zap; newrec: zap);
var r: zap; g: file of zap;
begin
assign(g,'l.dat');
rewrite(g);
reset(fizap);
while not eof(f) do
begin read (f,r);
if newrec.quantity < r.quantity then break
else if(newrec.name <> r.name) then write(g,r)
end;
write(g,newrec);
if not eof(f) then if(newrec.name <> r.name) then write(g,r);
while not eof(f) do
begin read (f,r);
if(newrec.name <> r.name) then write(g,r);
end;
rewrite(fizap);
reset(g);
repeat
read(g,a);
write(fizap,a);
until eof(g);
close(g);
close(fizap);
erase(g);
end;
begin
assign(fizap,'res.dat'); rewrite(fizap);
s1.name:='';
s1.cost:=1500;
s1.date:=1989;
s1.quantity:=15;
write(fizap,s1);
s1.name:='';
s1.cost:=21500;
s1.date:= 1990;
s1.quantity:=212;
write(fizap,s1);
s1.name:='';
s1.cost:=500;
s1.date:=1998;
s1.quantity:=50;
write(fizap,s1);
s1.name:='';
s1.cost:=200;
s1.date:=2000;
s1.quantity:=165;
write(fizap,s1);
s1.name:='';
s1.cost:=1500;
s1.date:=2001;
s1.quantity:=78;
write(fizap,s1);
s1.name:='';
s1.cost:=1000;
s1.date:=2005;
s1.quantity:=710;
write(fizap,s1);
s1.name:='';
s1.cost:=21500;
s1.date:=2005;
s1.quantity:=76;
write(fizap,s1);
s1.name:='';
s1.cost:=500;
s1.date:=2011;
s1.quantity:=577;
write(fizap,s1);
s1.name:='';
s1.cost:=200;
s1.date:=2012;
s1.quantity:=185;
write(fizap,s1);
s1.name:='';
s1.cost:=1000;
s1.date:=2012;
s1.quantity:=100;
write(fizap,s1);
s1.name:='';
s1.cost:=21500;
s1.date:=2013;
s1.quantity:=126;
write(fizap,s1);
|
|
s1.name:='';
s1.cost:=500;
s1.date:=2014;
s1.quantity:=124;
write(fizap,s1);
s1.name:='';
s1.cost:=200;
s1.date:=2015;
s1.quantity:=274;
write(fizap,s1);
close(fizap);
writeln(' -- --');
PrintFile(fizap);
s1.name:='';
s1.cost:=200;
s1.date:=2005;
s1.quantity:=5;
InSortfile(fizap, s1);
writeln(' -- `` --');
PrintFile(fizap);
s1.name:='';
s1.cost:=28400;
s1.date:=2004;
s1.quantity:=10;
InSortfile(fizap, s1);
writeln(' -- `` --');
PrintFile(fizap);
s1.name:='';
s1.cost:=1200;
s1.date:=2015;
s1.quantity:=22;
InSortfile(fizap, s1);
writeln(' -- `` --');
PrintFile(fizap);
s1.name:='';
s1.cost:=3500;
s1.date:=2010;
s1.quantity:=254;
InSortfile(fizap, s1);
writeln(' -- `` --');
PrintFile(fizap);
s1.name:='';
s1.cost:=1200;
s1.date:=2015;
s1.quantity:=122;
InSortfile(fizap, s1);
writeln(' -- `` --');
PrintFile(fizap);
s1.name:='';
s1.cost:=3500;
s1.date:=2010;
s1.quantity:=54;
InSortfile(fizap, s1);
writeln(' -- `` --');
PrintFile(fizap);
end.
: