Ошибка в том:
Найти три точки: Самую высшую,самую левую и самую правую точки.Построить треугольник! А он не строит((
Код:
procedure TForm1.Button1Click(Sender: TObject);
var q,p,s,i,n,m,j,h,b,b1,b2,b3:integer;
x,y:real;
a:array[1..30] of TPoint;
m1:array[1..3] of TPoint;
begin
memo1.Clear;
for i:=1 to strtoint(edit3.Text) do
begin
randomize;
with image1.canvas do
begin
n:=(image1.width-250-strtoint(edit2.Text)*3)+random(image1.width-80);
m:=(image1.Height-250-strtoint(edit2.Text)*3)+random(image1.Height-50);
x:=n;
y:=m;
memo1.Lines.Add('№'+inttostr(i)+' ('+floattostrf(x,fffixed,3,0)+':'+floattostrf(y,fffixed,3,0)+')');
p:=10+random(385);
s:=10+random(385);
image1.Canvas.Pen.Width:=5;
image1.Canvas.Pen.Color:=clGreen;
image1.Canvas.Ellipse(n-1,image1.Height-(m-1),n+1,image1.Height-(m+1));
image1.Canvas.TextOut(n,image1.Height-(m),'№'+inttostr(i));
a[i].X:=n;
a[i].Y:=m;
end;
image1.Canvas.Pen.Width:=1;
image1.Canvas.Pen.Color:=clblack;
image1.Canvas.Font.Size:=7;
memo1.Visible:=true;
end;
m1[1].Y:=a[1].y;
for b:=1 to strtoint(edit3.Text) do
if (a[b].Y>m1[1].Y)
then begin m1[1].Y:=a[b].Y;
m1[1].X:=a[b].X;
end;
m1[2].X:=a[1].X;
for b:=1 to strtoint(edit3.Text) do
if (a[b].X>m1[2].X)
then begin m1[2].X:=a[b].X;
m1[2].Y:=a[b].Y;
end;
m1[3].X:=a[1].X;
for b:=1 to strtoint(edit3.Text) do
if (a[b].X<m1[3].X)
then begin m1[3].X:=a[b].X;
m1[3].Y:=a[b].Y;
end;
image1.Canvas.MoveTo(m1[1].X,image1.Height-m1[1].Y);
image1.Canvas.LineTo(m1[2].X,image1.Height-m1[2].Y);
image1.Canvas.MoveTo(m1[2].X,image1.Height-m1[2].Y);
image1.Canvas.LineTo(m1[3].X,image1.Height-m1[3].Y);
image1.Canvas.MoveTo(m1[3].X,image1.Height-m1[3].Y);
image1.Canvas.LineTo(m1[1].X,image1.Height-m1[1].Y);
end;