Задача №1
PROGRAM P3;
uses crt,Graph;
CONST
FileName = 'library.txt';
max = 100;
TYPE
RecPoint = RECORD
X :INTEGER;
Y :INTEGER;
END;
TStat = array [1..max] of RecPoint;
TypeFile = File of RecPoint;
VAR
NewFile, FileP :TEXT;
Rec :TStat;
F :TypeFile;
x:byte;
Gd, Gm: Integer;
{ ------------------------- Procedure ReadRec ------------------------ }
PROCEDURE ReadRec(VAR stat :TStat;var tmpF: TypeFile);
VAR
i:byte;
BEGIN
clrscr;
assign(tmpF,Filename);
reset(tmpF);
i:=0;
while not eof(tmpF) do
begin
inc(i);
read(tmpF,stat[i]);
writeln(stat[i].X ,' - ', stat[i].Y);
end;
close(tmpF);
end;
procedure Sohr(var stat: TStat; var n:byte; var tmpF: TypeFile);
var
i:byte;
begin
Assign(tmpF,Filename);
Rewrite(tmpF);
for i:=1 to n do
begin
writeln('X: ', stat[i].X,' Y: ',
stat[i].Y);
write(tmpF, stat[i]);{запись в файл одной записи stat[i]}
end;
close(tmpF);{закрываем}
end;
procedure Vvod(var stat: TStat; var n:byte);
var
i:byte;
begin
write ('‚ўҐ¤ЁвҐ Є®«ЁзҐбвў® в®зҐЄ: ');
readln (n);
writeln;
for i:=1 to n do
begin
writeln('Ќ®ў*п в®зЄ*');
writeln('---------------------');
write('X:=: ');
readln(stat[i].X);
write('Y:=: ');
readln(stat[i].Y);
writeln('---------------------');
end;
stat[n+1].X := stat[1].X;
stat[n+1].Y := stat[1].Y;
writeln ('OK!');
writeln;
end;
{ --------------------------- Main Program --------------------------- }
BEGIN
clrscr;
Vvod(Rec,x);
Sohr(Rec,x,F);
ReadRec(Rec,F);
readkey;
clrscr;
{---Draw Figure---}
Gd := Detect;
InitGraph(Gd, Gm, '');
if GraphResult <> grOk then
Halt(1);
DrawPoly(x+1, Rec);
Readln;
CloseGraph;
END.