1)type ta=array[1..30,1..10] of Integer;
var ma:ta;
i,k,j:integer;
procedure SearchAndInc(ma:ta; var k:integer);
var i,j:integer;
begin;
for i:=1 to 30 do
for j:=1 to 10 do
if (i+j) mod 5=0 then k:=k+ma[i,j];
end;
begin;
randomize;
writeln('Matrix:');
for i:=1 to 30 do
begin;
writeln;
for j:=1 to 10 do
begin;
ma[i,j]:=random(50);
write(ma[i,j]:4);
end;
end;
SearchAndInc(ma,k);
writeln;
writeln('Result:',k);
end.
2)type
ta=array[1..20,1..5] of Integer;
procedure Minim(ma:ta;var mini,minj:integer);
var i,j,min:integer;
begin;
min:=2147483647;
for i:=1 to 20 do
begin;
for j:=1 to 5 do
begin;
if min>ma[i,j] then
begin;
min:=ma[i,j];
mini:=i;
minj:=j;
end;
end;
end;
end;
var ma:ta;
i,j,c,mini,minj,min:integer;
begin;
randomize;
writeln('Matrix:');
for i:=1 to 20 do
begin;
writeln;
for j:=1 to 5 do
begin;
ma[i,j]:=random(50);
write(ma[i,j]:4);
end;
end;
Minim(ma,mini,minj);
writeln;
c:=ma[1,2];
ma[1,2]:=ma[mini,minj];
ma[mini,minj]:=c;
writeln('Final matrix:');
for i:=1 to 20 do
begin;
writeln;
for j:=1 to 5 do
write(ma[i,j]:4);
end;
writeln;
writeln('Min:',min);
end.