uses crt;
type
strani=record
naz:string[20];
sq:integer;
nas:integer;
end;
plotnost=record
naz:string[20];
sq:integer;
nas:integer;
pl:real;
end;
var
i,j,k:integer;
a:strani;
b:plotnost;
f:file of strani;
f1:file of plotnost;
begin
clrscr;
assign(f,'strani.dat');
rewrite(f);
writeln('Введите число записей');readln(k);
for i:=1 to k do
begin
with a do
begin
writeln('Название страны ');readln(naz);
writeln('Площадь ');readln(sq);
writeln('Число населения ');readln(nas);
write(f,a);
end;
end;
close(f);
assign(f1,'plotnost.dat');
rewrite(f1);
reset(f);
seek(f,0);
while not eof(f) do begin
read(f,a);
for i:=1 to k-1 do begin
b.naz:=a.naz;
b.sq:=a.sq;
b.nas:=a.nas;
b.pl:=(a.nas)/(a.sq);
write(f1,b);
end;end;
close(f1);
close(f);
reset(f1);
writeln('Новый файл содержит:');
seek(f1,0);
writeln('СТРАНА','ПЛОЩАДЬ':16,'НАСЕЛЕНИЕ':8,'ПЛОТНОСТЬ':18);
while not eof(f1) do
begin
read(f1,b);
with b do
writeln(naz:4,sq:15,nas:10,pl:16:2);
end;
close(f1);
readln;
end.
База данных в типизированном файле |