procedure TForm1.Panel6Click(Sender: TObject);
Var
n, i, j, k, bar, iterasi, maxit:integer;
a:array[1..100,1..100]of real;
x,xlama:array[1..100]of real;
sum, e, epsilon:real;
begin
n:=stringgrid1.RowCount-1;
maxit:=strtoint(edit4.Text);
epsilon:=strtofloat(edit5.Text);
for i:=1 to n do
for j:=1 to n+1 do
begin
a[i,j]:=strtofloat(stringgrid1.Cells[j,i]);
end;
e:=1;
iterasi:=0;
while (e>epsilon) or (iterasi<maxit)do
begin
iterasi:=iterasi+1;
for i:=1 to n do
begin
sum:=a[i,n+1];
for j:=1 to n do
if j<>i then
sum:=sum-x[j]*a[i,j];
xlama[i]:=x[i];
x[i]:=sum/a[i,i];
e:=abs((x[i]-xlama[i])/x[i]);
stringgrid2.cells[i,iterasi]:=floattostr(x[i]);
stringgrid2.Cells[0,iterasi]:=inttostr(iterasi);
stringgrid2.Cells[i,0]:='x'+inttostr(i);
end;
stringgrid2.RowCount:=iterasi+1;
end;
end;
procedure TForm1.Panel7Click(Sender: TObject);
Var
n,m,i,j,k,l,o,p:integer;
begin
edit4.Text:='';
edit5.Text:='';
for i:=0 to stringgrid1.colcount-1 do
stringgrid1.Cols[i].Clear;
for i:=0 to stringgrid2.colcount-1 do
stringgrid2.Cols[i].Clear;
end;
procedure TForm1.Panel8Click(Sender: TObject);
begin
close;
end;
end.
Sabtu, 19 November 2016
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar