Const Nmax=100;
Type IndexType=1..Nmax;
Matrix=Array[IndexType,IndexType] of Longint;
Function Simple_number(A:Longint): Boolean;
Var d,b : Word;
Begin
A:=Abs(A);
If A<2 then begin
Simple_number:=False;
Exit;
End;
Simple_number:=True;
b:= trunc(sqrt(A));
For d:=2 to b do begin
If (A mod d)=0 then begin
Simple_number:=False;
break;
End;
End;
End;
Function exist_3(A:Longint): Boolean;
Var q,p :Longint;
Begin
A:=Abs(A);
q:=A;
exist_3:=False;
While q>0 do begin
p:=q mod 10;
If p=3 then begin
exist_3:=True;
Exit;
End;
q:=q div 10;
End;
End;
Procedure Change(Var A:Matrix; n:IndexType);
Var i,j :IndexType;
max :Longint;
Begin
max:=low(Longint);
j:=1;
While j<=n do begin
For i:=1 to n do begin
If A[i,j]>max then max:=A[i,j];
End;
A[j,j]:=max;
inc(j);
End;
End;
Procedure Out(A:Matrix; n:IndexType);
Var i,j :IndexType;
Begin
Writeln;
For i:=1 to n do begin
For j:=1 to n do write(A[i,j]);
Write(#10#13,#10#13);
End;
End;
Var A :Matrix;
i,j,n,m :Integer;
count :Word;
Begin
Repeat
Write('Vvedite parametri matrici(n<100)');
Read(n);
m:=n;
Writeln('Matrix:');
Until (n>=1) and (n<=Nmax);
For i:=1 to n do begin
For j:=1 to n do Read(A[i,j]);
End;
count:=0;
For j:=1 to n do begin
For i:=1 to n do Simple_number(A[i,j]);
If Simple_number(A[i,j]) then begin
exist_3(A[i,j]);
If exist_3(A[i,j]) then inc(count);
End;
End;
If (count=m) and (exist_3(A[i,j])) then begin
Change(A,n);
end;
for i:=1 to n do begin
for j:=1 to n do write(a[i,j]:5);
writeln;
end;
readln;
End.
задача на матрицы |