![]() |
|
#19
|
||||
|
||||
![]() Целесообразно использовать массив.
Код:
procedure TForm1.Button1Click(Sender: TObject); var i: integer; ar: array [0..5] of real; min, max, scale: real; begin ar[0]:=strtofloat(edit1.Text); ar[1]:=strtofloat(edit2.Text); ar[2]:=strtofloat(edit3.Text); ar[3]:=strtofloat(edit4.Text); ar[4]:=strtofloat(edit5.Text); ar[5]:=strtofloat(edit6.Text); min:=0; max:=0; for i:=0 to length(ar)-1 do begin if ar[i]>max then max:=ar[i]; if ar[i]<min then min:=ar[i]; end; scale:=image1.Height/(max-min); image1.Canvas.MoveTo(0, image1.Height-round((ar[0]-min)*scale)); for i:=0 to length(ar)-1 do begin image1.Canvas.LineTo(round(i*image1.Width/(length(ar)-1)), image1.Height-round((ar[i]-min)*scale)); end; end; |