Transpose an arbitrarily sized rectangular Matrix.




OPTION BASE 0
DIM matriz(3, 4)
DATA 78, 19, 30, 12, 36
DATA 49, 10, 65, 42, 50
DATA 30, 93, 24, 78, 10
DATA 39, 68, 27, 64, 29
 
FOR f = 0 TO 3
    FOR c = 0 TO 4
        READ matriz(f, c)
    NEXT c
NEXT f
 
DIM mtranspuesta(0 TO 4, 0 TO 3)
 
FOR fila = LBOUND(matriz,1) TO UBOUND(matriz,1)
    FOR columna = LBOUND(matriz,2) TO UBOUND(matriz,2)
        LET mtranspuesta(columna, fila) = matriz(fila, columna)
        PRINT matriz(fila, columna);
    NEXT columna
    PRINT
NEXT fila
PRINT
 
FOR fila = LBOUND(mtranspuesta,1) TO UBOUND(mtranspuesta,1)
    FOR columna = LBOUND(mtranspuesta,2) TO UBOUND(mtranspuesta,2)
        PRINT mtranspuesta(fila, columna);
    NEXT columna
    PRINT
NEXT fila
END