langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
46
Task/Matrix-transposition/Seed7/matrix-transposition.seed7
Normal file
46
Task/Matrix-transposition/Seed7/matrix-transposition.seed7
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "float.s7i";
|
||||
|
||||
const type: matrix is array array float;
|
||||
|
||||
const func matrix: transpose (in matrix: aMatrix) is func
|
||||
result
|
||||
var matrix: transposedMatrix is matrix.value;
|
||||
local
|
||||
var integer: i is 0;
|
||||
var integer: j is 0;
|
||||
begin
|
||||
transposedMatrix := length(aMatrix[1]) times length(aMatrix) times 0.0;
|
||||
for i range 1 to length(aMatrix) do
|
||||
for j range 1 to length(aMatrix[1]) do
|
||||
transposedMatrix[j][i] := aMatrix[i][j];
|
||||
end for;
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const proc: write (in matrix: aMatrix) is func
|
||||
local
|
||||
var integer: line is 0;
|
||||
var integer: column is 0;
|
||||
begin
|
||||
for line range 1 to length(aMatrix) do
|
||||
for column range 1 to length(aMatrix[line]) do
|
||||
write(" " <& aMatrix[line][column] digits 2);
|
||||
end for;
|
||||
writeln;
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const matrix: testMatrix is [] (
|
||||
[] (0.0, 0.1, 0.2, 0.3),
|
||||
[] (0.4, 0.5, 0.6, 0.7),
|
||||
[] (0.8, 0.9, 1.0, 1.1));
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
writeln("Before Transposition:");
|
||||
write(testMatrix);
|
||||
writeln;
|
||||
writeln("After Transposition:");
|
||||
write(transpose(testMatrix));
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue