Ребята! Привет! Я не могу теперь ко второй задачи которую вы решили написать комментарии
. Я знаю только про цвет
Код:
uses
graph,
crt;
const K = 10; {kol-vo tochek}
type tPoint = record
x, y: real;
n: integer;
end; { record}
type tPoints = array [1..K] of tPoint;
procedure dec2pol (var p: tPoint);
var t: tPoint;
begin { dec2pol }
t. n := p. n;
if p. x = 0 then begin
if p. y = 0 then
t. x := 0
else
t. x := 90;
end else
t. x := 180 * arctan (p. y / p. x) / Pi;
t. y := sqrt (sqr (p. x) + sqr (p. y));
p := t;
end; { dec2pol }
procedure swap (var x, y: tPoint);
var t: tPoint;
begin { swap}
t := x;
x := y;
y := t;
end; { swap}
procedure transit (p1: tPoint; var p2: tPoint);
begin { transit}
p2. x := p2. x - p1. x;
p2. y := p2. y - p1. y;
end; { transit }
var points: tPoints;
t, p1, p2: tPoint;
i, j, N: integer;
grDriver, grMode: integer;
minXY: tPoint;
begin { main program }
minXY. x := 0;
minXY. y := 0;
Write('Vvedite kolichestvo tochek (do 10-ti): ');
ReadLn(N);
WriteLn('Vvedite koordinaty tochek. -320<x<320 -240<y<240');
for i := 1 to N do begin
points [i]. n := i;
Write('Tochka ', i, ':');
readLn (points [i]. x, points [i]. y);
end; {for}
minXY := points [1];
for i := 2 to N do begin
if (points [i]. x < minXY. x) then
minXY. x := points [i]. x;
if (points [i]. y < minXY. y) then
minXY. y := points [i]. y;
end;
for i := 1 to N - 1 do begin
p1 := points [i];
transit (minXY, p1);
dec2pol (p1);
for j := i + 1 to N do begin
p2 := points [j];
transit (minXY, p2);
dec2pol (p2);
if p2. x < p1. x then begin
swap (points [i], points [j]);
swap (p1, p2);
end; { if }
end; { for }
end; { for }
for i := 1 to N - 1 do begin
p1 := points [i];
transit (minXY, p1);
dec2pol (p1);
for j := i + 1 to N do begin
p2 := points [j];
transit (minXY, p2);
dec2pol (p2);
if (p2. x = p1. x) and (p2. y < p2. y) then begin
swap (points [i], points [j]);
swap (p1, p2);
end; { if }
end; { for }
end; { for }
{vyvod poryadka obchoda tochek}
write('Poryadok obhoda tochek: ');
for i := 1 to N do
Write(points [i]. n : 3);
WriteLn;
Write ('Zamknutaja lomannaja - nagmi <Enter>');
ReadLn;
{risuem lomannuu}
grDriver := 9;
grMode := 2;
InitGraph (grDriver, grMode, 'С:\BP\BGI');
if GraphResult = grOk then begin
ClearDevice;
MoveTo (320, 0);
LineTo (320, 480);
MoveTo (0, 240);
LineTo (640, 240);
MoveTo (320 + trunc (points [1]. x), 240 - trunc (points [1]. y));
setcolor(13); {choby lomannaja ne slivalas s osyami koordinat, i potomu chto
tak krasivee};
for i := 2 to N do
LineTo (320 + trunc (points [i]. x), 240 - trunc (points [i]. y));
LineTo (320 + trunc (points [1]. x), 240 - trunc (points [1]. y));
while not KeyPressed do ;
end else
Writeln ('graph initialization fault');
CloseGraph;
end. {main program}