
03.03.2013, 21:22
|
Прохожий
|
|
Регистрация: 14.02.2013
Сообщения: 17
Репутация: 10
|
|
Вообщем я немного изменил код, как вы сказали заранее присвоил значения для t. Пришлось массивов сделать несколько штук. Вот код:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Series, TeEngine, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Chart1: TChart;
Series1: TLineSeries;
Series2: TPointSeries;
Button1: TButton;
Button2: TButton;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
y: array [1..100] of real;
x: array [1..100] of real;
q: array [1..100] of real;
L: array [1..100] of real;
t: array [1..100] of real;
n,i,j,g,k:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const t='Введите значение';
begin
n:=strtoint(edit1.text);
for i:=0 to n-1 do
begin
x[i]:=StrToFloat(InputBox('Ввод X'+IntToStr(i),t,'0'));
y[i]:=StrToFloat(InputBox('Ввод Y'+IntToStr(i),t,'0'));
series2.AddXY(x[i],y[i]);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
n:=strtoint(edit1.text);
for k:=0 to n-1 do begin
t[k]:=k/10;
end;
for k:=0 to n-1 do begin
q[k]:=1;
end;
for k:=0 to n-1 do begin
L[k]:=0;
end;
if (i<j) and (i>j) then begin /
for i:=0 to n-1 do begin
for j:=0 to n-1 do begin
q[k]:=q[k]*(t[k]-x[j])/(x[i]-x[j]);
end;
L[k]:=L[k]+q[k]*y[i];
end;
end;
for k:=1 to n-1 do begin
series1.AddXY(t[k],L[k]);
end;
end;
end.
|