TRS=array[1..2] of Real;
{二元一次方程 高斯消元法计算函数}
function X1Y1_2(const ia1,ib1,ic1,ia2,ib2,ic2:Real):TRS;
const //为数组的行数与列数
Rows = 2;
Cols = 3;
var
C: array[1..Rows, 1..Cols] of Real; //系数及常数项
R1, R2: Real;
m,n,i: Integer;
begin
C[1,1]:=ia1;
C[1,2]:=ib1;
C[1,3]:=ic1;
C[2,1]:=ia2;
C[2,2]:=ib2;
C[2,3]:=ic2;
//高斯消元
for n := 1 to Rows do
begin
R1 := C[n,n];
for m := 1 to Cols do C[n,m] := C[n,m] / R1; //使每个方程对角线上的系数为1
for i := 1 to Rows do
if i <> n then //依次对其它方程的第n项进行消元
begin
R2 := C[i,n];
for m := 1 to Cols do C[i,m] := C[i,m] - C[n,m]*R2;
end;
end;
Result[1]:=C[1,3];
Result[2]:=C[2,3];
end;