vksaharkov
а можешь сделать без флага? типа такого: const n=5; m=6; var a:array [1..5,1..6] of integer; i,j,k,l,c:integer; Begin writeln('Ведите номер меняемых элементов'); readln(k,l); for j:=1 to m do begin c:=a[k,j]; a[k,j]:=a[l,j]; a[l,j]:=c; end; writeln('Новый массив => '); for i:=1 to n do begin for j:=1 to m do write(a[i,j],' '); writeln; end; readln; readln end.
Answers & Comments
var
a: array [1..5,1..6] of integer;
i,j,sum,ip,jp:integer;
flag:boolean;
begin
flag:=false;
sum:=0;
for i:=1 to 5 do
begin
for j:= 1 to 6 do
begin
a[i,j]:=random(31)-10;
write(a[i,j]:4);
if a[i,j] mod 2 = 0 then
sum:=sum+a[i,j];
if not flag then
if abs(a[i,j] mod 2) = 1 then
begin
flag:=true;
ip:=i;
jp:=j;
end;
end;
writeln;
end;
a[ip,jp]:=sum;
writeln;
for i:=1 to 5 do
begin
for j:=1 to 6 do
write(a[i,j]:4);
writeln;
end;
end.
const n=5; m=6;
var a:array [1..5,1..6] of integer;
i,j,k,l,c:integer;
Begin
writeln('Ведите номер меняемых элементов');
readln(k,l);
for j:=1 to m do
begin
c:=a[k,j];
a[k,j]:=a[l,j];
a[l,j]:=c;
end;
writeln('Новый массив => ');
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j],' ');
writeln;
end;
readln;
readln
end.