помогите решить задачу пожалуйста
дана матрица K(5,4), вывести значение по столбцам. Переставить элементов заданных столбцов (второго и третьего). Вывести результат по строкам. написать программу
- У вас тут зачет по паскалю, что-ли? Ща, напишу ) от forumsreg, 22 ноября 2012 года
Код:
program Transpose; {Transpose array}
uses Crt; {module for clrscr and readkey}
type
mas = array[1..5, 1..4] of real;
var
i, j: integer;
t: real;
K: mas;
begin
ClrScr; {clearing screen}
for j := 1 to 4 do begin
WriteLn('Input ', j, ' column:');
for i := 1 to 5 do begin
ReadLn(K[i,j]);
end;
end;
for i := 1 to 5 do begin
t := K[i,2];
K[i,2] := K[i,3];
K[i,3] := t;
end;
for i := 1 to 5 do begin
WriteLn('Row ', i, ':');
for j := 1 to 4 do begin
Write(K[i,j]:6:3, ' ');
end;
WriteLn('');
end;
Write('Press any key to continue . . .');
ReadKey; {wait for the key pressing}
end.
uses Crt; {module for clrscr and readkey}
type
mas = array[1..5, 1..4] of real;
var
i, j: integer;
t: real;
K: mas;
begin
ClrScr; {clearing screen}
for j := 1 to 4 do begin
WriteLn('Input ', j, ' column:');
for i := 1 to 5 do begin
ReadLn(K[i,j]);
end;
end;
for i := 1 to 5 do begin
t := K[i,2];
K[i,2] := K[i,3];
K[i,3] := t;
end;
for i := 1 to 5 do begin
WriteLn('Row ', i, ':');
for j := 1 to 4 do begin
Write(K[i,j]:6:3, ' ');
end;
WriteLn('');
end;
Write('Press any key to continue . . .');
ReadKey; {wait for the key pressing}
end.
Код:
program Transpose; {Transpose array}
uses Crt; {module for clrscr and readkey}
type
mas = array[1..5, 1..4] of real;
var
K: mas;
procedure input(var K: mas);
var
i, j: integer;
begin
for j := 1 to 4 do begin
WriteLn('Input ', j, ' column:');
for i := 1 to 5 do begin
ReadLn(K[i,j]);
end;
end;
end;
procedure swap(var K: mas; a,b: integer);
var
i: integer;
t: real;
begin
for i := 1 to 5 do begin
t := K[i,a];
K[i,a] := K[i,b];
K[i,b] := t;
end;
end;
procedure output(var K: mas);
var
i, j: integer;
begin
for i := 1 to 5 do begin
WriteLn('Row ', i, ':');
for j := 1 to 4 do begin
Write(K[i,j]:6:3, ' ');
end;
WriteLn('');
end;
end;
begin
ClrScr; {clearing screen}
input(K);
swap(K,2,3);
output(K);
Write('Press any key to continue . . .');
ReadKey; {wait for the key pressing}
end.
uses Crt; {module for clrscr and readkey}
type
mas = array[1..5, 1..4] of real;
var
K: mas;
procedure input(var K: mas);
var
i, j: integer;
begin
for j := 1 to 4 do begin
WriteLn('Input ', j, ' column:');
for i := 1 to 5 do begin
ReadLn(K[i,j]);
end;
end;
end;
procedure swap(var K: mas; a,b: integer);
var
i: integer;
t: real;
begin
for i := 1 to 5 do begin
t := K[i,a];
K[i,a] := K[i,b];
K[i,b] := t;
end;
end;
procedure output(var K: mas);
var
i, j: integer;
begin
for i := 1 to 5 do begin
WriteLn('Row ', i, ':');
for j := 1 to 4 do begin
Write(K[i,j]:6:3, ' ');
end;
WriteLn('');
end;
end;
begin
ClrScr; {clearing screen}
input(K);
swap(K,2,3);
output(K);
Write('Press any key to continue . . .');
ReadKey; {wait for the key pressing}
end.