max ,min ,maxint函数没有问题
procedure TForm5.Button2Click(Sender: TObject);
var
t:array[1..3]of real;
k:array[1..3]of integer;
x1,y1,x2,y2,x3,y3:real;
xm,xn,x,y,num,i,j:integer;
ym,yn:integer;
a12,b12,a13,b13,a23,b23,g:real;
begin
num:=0;i:=0;j:=0;x:=0;y:=0;
x1:=strtofloat(edit1.text);
y1:=strtofloat(edit2.text);
x2:=strtofloat(edit3.text);
y2:=strtofloat(edit4.text);
x3:=strtofloat(edit5.text);
y3:=strtofloat(edit6.text);
if (edit1.text<>'') and (edit2.text<>'')then
begin
ym:=max(y1,y2,y3);
yn:=min(y1,y2,y3);
//
xm:=max(x1,x2,x3);
xn:=min(x1,x2,x3);
a12:=(y1-y2)/(x1-x2);
b12:=y1-a12*x1;
a13:=(y1-y3)/(x1-x3);
b13:=y1-a13*x1;
a23:=(y3-y2)/(x3-x2);
b23:=y3-a23*x3;
j:=0;
y:=0;
for y:=yn to ym do
begin
g:=y+0.5;
t[1]:=(g-b12)/a12;
t[2]:=(g-b13)/a13;
t[3]:=(g-b23)/a23;
k[3]:=0;
for i:=1 to 3 do
begin
if (t[i]>=xn) and (t[i]<=xm) then
begin
j:=j+1;
k[j]:=round(t[i]+0.5);
end
end;
num:=xm;
for i:=1 to j do
begin
if (k[i]<=num) and (k[i]>=xn) then
begin
num:=k[i];
end;
end;
for x:=num to maxint(k[1],k[2],k[3]) do
begin
form1.PaintBox1.Canvas.Pixels[round(x),round(y)]:=clblue;
end;
end;
end;
end;
为什么设置断点检查的时候,XN,XM都有值,YN,YM却没有。不胜感激