100 баллов, помогите. Информатика, Паскаль решить две задачи. Срочно.
1) Дан двумерный массив размером 6*6. Поменять 1 столбец с 6, 2 столбец с 5, 3 столбец с 4.
2) Дан двумерный массив размером 6*6. Поменять 1 строку с 1 столбцом, 2 строку со 2 столбцом, 3 строку с 3 столбцом, 4 строку с 4 столбцом, 5 строку с 5 столбцом, 6 строку с 6 столбцом.
Answers & Comments
var
i, j: integer;
ar: array[1..6, 1..6]of integer;
begin
for i := 1 to 6 do
for j := 1 to 6 do read(ar[i, j]);
writeln;
for i := 1 to 6 do swap(ar[i, 1], ar[i, 6]);
for i := 1 to 6 do swap(ar[i, 2], ar[i, 5]);
for i := 1 to 6 do swap(ar[i, 3], ar[i, 4]);
for i := 1 to 6 do begin
for j := 1 to 6 do write(ar[i, j], ' ');
writeln;
end;
end.
2)
var
mr, rm: array [1..6, 1..6] of integer;
i, j: integer;
begin
for i := 1 to 6 do
for j := 1 to 6 do read(mr[i, j] );
for i := 1 To 6 do
for j := 1 To 6 do
rm[i, j] := mr[j, i];
writeLn;
for i := 1 to 6 do
begin
for j := 1 to 6 do write(rm[i, j],' ');
writeln;
end;
readln;
end.
Verified answer
{1}const
n = 6;
var
a:array[1..n,1..n] of integer;
i,j:integer;
t:integer;
begin
for i := 1 to n do
for j := 1 to n do
read(a[i,j]);
for j := 1 to n div 2 do
for i := 1 to n do
begin
t := a[i,j];
a[i,j] := a[i,n+1-j];
a[i,n+1-j] := t;
end;
for i := 1 to n do
begin
writeln;
for j := 1 to n do
write(a[i,j],' ');
end
end.
{2}
const
n = 6;
var
a:array[1..n,1..n] of integer;
i,j:integer;
t:integer;
begin
for i := 1 to n do
for j := 1 to n do
read(a[i,j]);
for i := 1 to n do
for j := i+1 to n do
begin
t := a[i,j];
a[i,j] := a[j,i];
a[j,i] := t;
end;
for i := 1 to n do
begin
writeln;
for j := 1 to n do
write(a[i,j],' ');
end
end.