这是我学校的作业,在delphi中进行高斯乔丹消除,但是..我在这里遇到了一些问题......
我做了这样的:
procedure TForm1.Button3Click(Sender: TObject);
var
n,i,j,k,bar,kol:integer;
a:array [1..100,1..100]of real;
x:array [1..100]of real;
faktor:real;
begin
memo1.Clear;
n:=stringgrid2.RowCount-1;
kenalmatriks;
StringGrid2.RowCount := baris;
StringGrid2.ColCount := kolom;
for i:=1 to n do
begin
for j:=1 to n+1 do
begin
a[i,j]:=strtofloat(stringgrid1.cells[j,i]);
end;
end;
for k:=1 to n do
begin
faktor:=a[k,k];
for j:=1 to n+1 do
begin
a[j,k]:=a[j,k]/faktor;
end;
for i:=1 to n do
begin
if i<>k then
begin
faktor:=a[i,k];
for j:=1 to n+1 do
begin
a[i,j]:=a[i,j]-faktor*a[k,j];
end;
end;
end;
end;
for bar:=1 to n do
begin
for kol:=1 to n+1 do
begin
stringgrid2.cells[kol,bar]:=floattostr(a[bar,kol]);
end;
end;
end;
结果必须是这样的:
1 0 0 2
0 1 0 7
0 0 1 -3
但是,我的:
-- -- -- --
-- 1 0 15.33
-- 0 1 2
我希望我能完成这个...... :(任何人......请帮助......