Procedure SimpleProc(var ma:ty); Var i,j,c:integer; begin for j:=1 to m do for i:=1 to n div 2 do begin c:=ma[i,j]; ma[i,j]:=ma[m-i-1,j]; ma[m-i-1,j]:=c; end; end;
Var ma:ty; i,j,sum,max,x,y:integer; begin randomize; writeln('First matrix:'); for i:=1 to n do begin for j:=1 to m do begin ma[i,j]:=random(10); write(ma[i,j]:4); end; writeln; end; SimpleProc(ma); //симметрия writeln('Final matrix:'); for i:=1 to n do begin for j:=1 to m do write(ma[i,j]:4); writeln; end; SimpleProc(ma); //Возвращаем в прежнее положение readln(x); for j:=1 to m do sum:=sum+ma[x,j]; writeln('Sum=',sum); max:=Integer.MinValue; readln(y); for i:=1 to n do if max<ma[i,y] then max:=ma[i,y]; writeln('Max=',max); end.
//1
Const n=4;
Var ar:array[1..n] of integer; ar2:array[1..n] of integer; i,min,sum,j,i1,i2:integer; begin randomize; writeln('First array:'); for i:=1 to n do begin ar[i]:=random(100)-50; write(ar[i]:4); end; min:=abs(ar[1]); for i:=2 to n do if abs(ar[i])<min then min:=abs(ar[i]); for i:=1 to n do if ar[i]=0 then begin for j:=i to n do sum:=sum+ar[j]; break; end; writeln; writeln('Sum=',sum); writeln('Final array:'); i2:=n; i1:=1; for i:=1 to n do if not odd(i) then begin ar2[i1]:=ar[i]; inc(i1); end else begin ar2[i2]:=ar[i]; dec(i2); end; for i:=1 to n do begin ar[i]:=ar2[i]; write(ar[i]:4); end; end.
Answers & Comments
Verified answer
//Pascal ABC.NET v3.1 сборка 1172//2
Const
n=4;
m=6;
Type
ty=array[1..n,1..m] of integer;
Procedure SimpleProc(var ma:ty);
Var
i,j,c:integer;
begin
for j:=1 to m do
for i:=1 to n div 2 do
begin
c:=ma[i,j];
ma[i,j]:=ma[m-i-1,j];
ma[m-i-1,j]:=c;
end;
end;
Var
ma:ty;
i,j,sum,max,x,y:integer;
begin
randomize;
writeln('First matrix:');
for i:=1 to n do
begin
for j:=1 to m do
begin
ma[i,j]:=random(10);
write(ma[i,j]:4);
end;
writeln;
end;
SimpleProc(ma); //симметрия
writeln('Final matrix:');
for i:=1 to n do
begin
for j:=1 to m do
write(ma[i,j]:4);
writeln;
end;
SimpleProc(ma); //Возвращаем в прежнее положение
readln(x);
for j:=1 to m do
sum:=sum+ma[x,j];
writeln('Sum=',sum);
max:=Integer.MinValue;
readln(y);
for i:=1 to n do
if max<ma[i,y] then max:=ma[i,y];
writeln('Max=',max);
end.
//1
Const
n=4;
Var
ar:array[1..n] of integer;
ar2:array[1..n] of integer;
i,min,sum,j,i1,i2:integer;
begin
randomize;
writeln('First array:');
for i:=1 to n do
begin
ar[i]:=random(100)-50;
write(ar[i]:4);
end;
min:=abs(ar[1]);
for i:=2 to n do
if abs(ar[i])<min then min:=abs(ar[i]);
for i:=1 to n do
if ar[i]=0 then
begin
for j:=i to n do
sum:=sum+ar[j];
break;
end;
writeln;
writeln('Sum=',sum);
writeln('Final array:');
i2:=n;
i1:=1;
for i:=1 to n do
if not odd(i) then
begin
ar2[i1]:=ar[i];
inc(i1);
end
else
begin
ar2[i2]:=ar[i];
dec(i2);
end;
for i:=1 to n do
begin
ar[i]:=ar2[i];
write(ar[i]:4);
end;
end.