Matrix transposition: Difference between revisions
Content added Content deleted
Line 1,337: | Line 1,337: | ||
class Transpose { |
class Transpose { |
||
function : Main(args : String[]) ~ Nil { |
function : Main(args : String[]) ~ Nil { |
||
input := [[1, 1, 1, 1] |
|||
m := [[1, 1, 1, 1] |
|||
[2, 4, 8, 16] |
[2, 4, 8, 16] |
||
[3, 9, 27, 81] |
[3, 9, 27, 81] |
||
[4, 16, 64, 256] |
[4, 16, 64, 256] |
||
[5, 25, 125, 625]]; |
[5, 25, 125, 625]]; |
||
dim := input->Size(); |
|||
output := Int->New[dim[0],dim[1]]; |
|||
for(i := 0; i < |
for(i := 0; i < dim[0]; i+=1;) { |
||
for(j := 0; j < |
for(j := 0; j < dim[1]; j+=1;) { |
||
output[i,j] := input[i,j]; |
|||
}; |
}; |
||
}; |
}; |
||
Print( |
Print(output); |
||
} |
} |
||
function : Print(matrix : Int[,] |
function : Print(matrix : Int[,]) ~ Nil { |
||
dim := matrix->Size(); |
|||
for(i := 0; i < dim[0]; i+=1;) { |
|||
for(j := 0; j < dim[1]; j+=1;) { |
|||
IO.Console->Print(matrix[i,j])->Print('\t'); |
IO.Console->Print(matrix[i,j])->Print('\t'); |
||
}; |
}; |