Нужна помощь!!!! Программа решения СЛАУ
в программе выводит две ошибки Invalid floating point operation и Floating point division by zero надо сделать так чтобы выводилось сообщение :ВВЕДИТЕ ДРУГИЕ ЗНАЧЕНИЯ
procedure TForm3.Button1Click(Sender: TObject);
var a: Matrix;
b,x: Vector;
h: Double;
i,j,k,n:integer;
begin
n := StrToIntDef(Text, StringGrid1.ColCount);
for j := 0 to n - 1 do
for i := 0 to n - 1 do
a[i + 1, j + 1] := StrToFloatDef(StringGrid1.Cells[j, i], 0);
for I := 0 to n - 1 do b[i + 1] := StrToFloatDef(StringGrid2.Cells[0, i], 0);
for i:=1 to n-1 do
for j:=i+1 to n do
begin
a[j,i]:=-a[j,i]/a[i,i];
for k:=i+1 to n do
a[j,k]:=a[j,k]+a[j,i]*a[i,k];
b[j]:=b[j]+a[j,i]*b
end;
x[n]:=b[n]/a[n,n];
for i:=n-1 downto 1 do
begin
h:=b;
for j:=i+1 to n do h:=h-x[j]*a[i,j];
x:=h/a[i,i]
end;
for i:=1 to n do ListBox1.Items.Append('x(' + IntToStr(i) + ')=' + FloatToStr(x));
end;
procedure TForm3.Edit1Change(Sender: TObject);
begin
with StringGrid1, Edit1 do
begin
ColCount := StrToIntDef(Text, 3);
RowCount := StrToIntDef(Text, 3);
end;
with StringGrid2, Edit1 do
RowCount := StrToIntDef(Text, 3)
end;
procedure TForm3.FormCreate(Sender: TObject);
var i, j: integer;
begin
Randomize;
for I := 0 to StrToIntDef(Text, StringGrid1.ColCount) - 1 do
for J := 0 to StrToIntDef(Text, StringGrid1.RowCount) - 1 do
StringGrid1.Cells[I, J] := IntToStr(Random(100));
for I := 0 to StrToIntDef(Text, StringGrid2.RowCount) - 1 do
StringGrid2.Cells[0, I] := IntToStr(Random(100))
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
listbox1.Items.Clear;
end;
end.