uses crt;
const nmax=20;
type matr=array [1..nmax,1..nmax] of integer;
mas=array [1..nmax] of integer;
var a: matr;
a1,a2,a3,a4: mas;
n,m: byte;
procedure Vvod (var z: matr; var ri,rj: byte);
var i,j: byte;
begin
repeat
write('Kol-vo strok, ne menee 4, ne bolee ',nmax,', n='); readln(ri);
until ri in [4..nmax];
write('Kol-vo stolbzov, ne bolee ',nmax,', n='); readln(rj);
until rj in [1..nmax];
writeln('Vvedite elementy matrizy:');
for i:=1 to ri do
for j:=1 to rj do
write('a[',i,',',j,']='); readln(z[i,j]);
end;
procedure Vivod (z: matr; ri,rj: byte);
writeln('Ischodnaja matriza');
write(z[i,j]:4);
writeln;
procedure Vivod1M (c: char; z: mas; rj: byte);
var j: byte;
writeln('Massiv ',c);
write(z[j]:4);
procedure MakeArray (ns: byte; x: matr; var y: mas; rj: byte);
y[j]:=x[ns,j];
function Jmin (z: mas; rj: byte): byte;
var j,jm: byte;
jm:=1;
if z[j]<z[jm] then jm:=j;
Jmin:=jm;
procedure Zamena (var z: mas; rj: byte);
var j: byte; g: integer;
g:=z[Jmin(z,rj)];
if Jmin(z,rj)<rj then
for j:=Jmin(z,rj)+1 to rj do
z[j]:=g;
Vvod (a,n,m);
clrscr;
Vivod (a,n,m);
MakeArray (1,a,a1,m);
MakeArray (2,a,a2,m);
MakeArray (3,a,a3,m);
MakeArray (4,a,a4,m);
writeln('Massivy do preobrazovania');
Vivod1M ('1',a1,m);
Vivod1M ('2',a2,m);
Vivod1M ('3',a3,m);
Vivod1M ('4',a4,m);
Zamena (a1,m);
Zamena (a2,m);
Zamena (a3,m);
Zamena (a4,m);
writeln('Massivy posle zameny');
readln;
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
uses crt;
const nmax=20;
type matr=array [1..nmax,1..nmax] of integer;
mas=array [1..nmax] of integer;
var a: matr;
a1,a2,a3,a4: mas;
n,m: byte;
procedure Vvod (var z: matr; var ri,rj: byte);
var i,j: byte;
begin
repeat
write('Kol-vo strok, ne menee 4, ne bolee ',nmax,', n='); readln(ri);
until ri in [4..nmax];
repeat
write('Kol-vo stolbzov, ne bolee ',nmax,', n='); readln(rj);
until rj in [1..nmax];
writeln('Vvedite elementy matrizy:');
for i:=1 to ri do
for j:=1 to rj do
begin
write('a[',i,',',j,']='); readln(z[i,j]);
end;
end;
procedure Vivod (z: matr; ri,rj: byte);
var i,j: byte;
begin
writeln('Ischodnaja matriza');
for i:=1 to ri do
begin
for j:=1 to rj do
write(z[i,j]:4);
writeln;
end;
end;
procedure Vivod1M (c: char; z: mas; rj: byte);
var j: byte;
begin
writeln('Massiv ',c);
for j:=1 to rj do
write(z[j]:4);
writeln;
end;
procedure MakeArray (ns: byte; x: matr; var y: mas; rj: byte);
var j: byte;
begin
for j:=1 to rj do
y[j]:=x[ns,j];
end;
function Jmin (z: mas; rj: byte): byte;
var j,jm: byte;
begin
jm:=1;
for j:=1 to rj do
if z[j]<z[jm] then jm:=j;
Jmin:=jm;
end;
procedure Zamena (var z: mas; rj: byte);
var j: byte; g: integer;
begin
g:=z[Jmin(z,rj)];
if Jmin(z,rj)<rj then
for j:=Jmin(z,rj)+1 to rj do
z[j]:=g;
end;
begin
Vvod (a,n,m);
clrscr;
Vivod (a,n,m);
MakeArray (1,a,a1,m);
MakeArray (2,a,a2,m);
MakeArray (3,a,a3,m);
MakeArray (4,a,a4,m);
writeln('Massivy do preobrazovania');
Vivod1M ('1',a1,m);
Vivod1M ('2',a2,m);
Vivod1M ('3',a3,m);
Vivod1M ('4',a4,m);
Zamena (a1,m);
Zamena (a2,m);
Zamena (a3,m);
Zamena (a4,m);
writeln('Massivy posle zameny');
Vivod1M ('1',a1,m);
Vivod1M ('2',a2,m);
Vivod1M ('3',a3,m);
Vivod1M ('4',a4,m);
readln;
end.