Const
N=3;
Type
Matrix=Array[1..N,1..N] of Integer;
Vector=Array[1..N] of Integer;
Var
A,B,C,W,D1,D2,D3:Matrix;
X,Y,U,R1,R2:Vector;
P,D:Integer;
Function Prod_Matr_Matr(T1,T2:Matrix):Matrix;
var i,j,k:byte;
begin
for i:=1 to N do
for j:=1 to N do
begin
Prod_Matr_Matr[i,j]:=0;
for k:=1 to N do
Prod_Matr_Matr[i,j]:=Prod_Matr_Matr[i,j]+T1[i,k]*T2[k,j];
end;
end;
Function Prod_Matr_Vect(T:Matrix; V:Vector):Vector;
var i,k:byte;
begin
for i:=1 to N do
begin
Prod_Matr_Vect[i]:=0;
for k:=1 to N do
Prod_Matr_Vect[i]:=Prod_Matr_Vect[i]+T[i,k]*V[k];
end;
end;
Function Prod_Matr_Numb(T:Matrix;W:Integer):Matrix;
var i,j:byte;
begin
for i:=1 to N do
for j:=1 to N do
Prod_Matr_Numb[i,j]:=T[i,j]*W;
end;
Function Sum_Matr_Matr(T1,T2:Matrix):Matrix;
var i,j:byte;
begin
for i:=1 to N do
for j:=1 to N do
Sum_Matr_Matr[i,j]:=T1[i,j]+T2[i,j];
end;
Function Dif_Matr_Matr(T1,T2:Matrix):Matrix;
var i,j:byte;
begin
for i:=1 to N do
for j:=1 to N do
Dif_Matr_Matr[i,j]:=T1[i,j]-T2[i,j];
end;
Function Min_Matr(T:Matrix):Integer;
var
i,j:byte;
m:Integer;
begin
m:=Abs(T[1,1]);
for i:=1 to N do
for j:=1 to N do
if Abs(T[i,j])<m then m:=Abs(T[i,j]);
Min_Matr:=m;
end;
Function Scal_Prod_Vect_Vect(V1,V2:Vector):Integer;
var
i:byte;
q:Integer;
begin
q:=0;
for i:=1 to N do
q:=q+V1[i]*V2[i];
Scal_Prod_Vect_Vect:=q;
end;
Function Sum_Vect_Vect(V1,V2:Vector):Vector;
var
i:byte;
begin
for i:=1 to N do
Sum_Vect_Vect[i]:=V1[i]+V2[i];
end;
Procedure Inp_Matr(G:Char; var T:Matrix);
var
i,j:byte;
begin
for i:=1 to N do
for j:=1 to N do
begin
write(G,'[',i,',',j,']= ');
readln(T[i,j]);
end;
writeln;
end;
Procedure Inp_Vect(G:Char; var V:Vector);
var
i:byte;
begin
for i:=1 to N do
begin
write(G,'[',i,']= ');
readln(V[i]);
end;
writeln;
end;
Procedure Out_Matr(T:Matrix);
var
i,j:byte;
begin
for i:=1 to N do
begin
for j:=1 to N do write(T[i,j]:8);
writeln;
end;
writeln;
end;
Procedure Out_Vect(V:Vector);
var
i:byte;
begin
for i:=1 to N do write(V[i]:8);
writeln;
writeln;
end;
Begin
Inp_Matr('A',A);
Inp_Matr('B',B);
Inp_Matr('C',C);
Inp_Vect('X',X);
Inp_Vect('Y',Y);
P:=Min_Matr(A);
D:=Scal_Prod_Vect_Vect(X,Y);
D1:=Prod_Matr_Numb(A,5);
D1:=Dif_Matr_Matr(C,D1);
D1:=Prod_Matr_Numb(D1,P);
D2:=Prod_Matr_Numb(C,4);
D2:=Sum_Matr_Matr(B,D2);
D2:=Prod_Matr_Numb(D2,D);
D3:=Prod_Matr_Matr(B,C);
D3:=Dif_Matr_Matr(A,D3);
D3:=Prod_Matr_Matr(B,D3);
D3:=Prod_Matr_Matr(D3,A);
D3:=Prod_Matr_Numb(D3,D);
W:=Sum_Matr_Matr(D1,D2);
W:=Dif_Matr_Matr(W,D3);
Writeln('Matrix W:');
Out_Matr(W);
Writeln;
D1:=Prod_Matr_Matr(C,B);
D1:=Sum_Matr_Matr(A,D1);
D1:=Prod_Matr_Numb(D1,D);
R1:=Prod_Matr_Vect(D1,X);
D1:=Prod_Matr_Matr(A,A);
D2:=Prod_Matr_Matr(B,B);
D3:=Prod_Matr_Matr(C,C);
D1:=Dif_Matr_Matr(D1,D2);
D1:=Sum_Matr_Matr(D1,D3);
D1:=Prod_Matr_Numb(D1,P);
R2:=Prod_Matr_Vect(D1,Y);
U:=Sum_Vect_Vect(R1,R2);
Writeln('Vector U:');
Out_Vect(U);
Readln
End.