Цитата:
Сообщение от gaben134
Помогите пожалуйста!
|
Помогаю:
Код:
Const
N=8;
Type
Matr=Array[1..N,1..N] of Integer;
Vect=Array[1..N] of Integer;
Var
i,j:byte;
A:Matr;
K:Vect;
t:boolean;
Sum:Integer;
Procedure Find_Equal(AFE:Matr; var KFE:Vect);
var
b:boolean;
p,q,m:byte;
begin
m:=0;
for p:=1 to N do
begin
b:=true;
for q:=1 to N do
if AFE[p,q]<>AFE[q,p] then b:=false;
if b then
begin
Inc(m);
KFE[m]:=p;
end;
end;
end;
Function Find_Sum(AFS:Vect):Integer;
var
p:byte;
S:Integer;
begin
S:=0;
for p:=1 to N do Inc(S,AFS[p]);
Find_Sum:=S;
end;
Begin
Randomize;
for i:=1 to N do
for j:=1 to N do
begin
A[i,j]:=-9+Random(10);
if (i=5) or (j=5) then A[i,j]:=5;
if i=7 then A[i,j]:=j;
if j=7 then A[i,j]:=i;
end;
for i:=1 to N do
begin
for j:=1 to N do Write(A[i,j]:4);
writeln;
end;
writeln;
Find_Equal(A,K);
if K[1]=0 then
Writeln('No such strings and columns!')
else
begin
Write('k: ');
i:=1;
repeat
if K[i]>0 then
begin
Write(K[i]:4);
Inc(i);
end;
until (K[i]=0) or (i>N);
end;
writeln;
writeln;
for i:=1 to N do
begin
t:=false;
for j:=1 to N do
if A[i,j]<0 then t:=true;
if t then
begin
Sum:=Find_Sum(A[i]);
Writeln('i = ',i,' Sum = ',Sum:4);
end;
end;
Readln;
End.