Matrix transposition: Difference between revisions
Content added Content deleted
(+ AutoHotkey) |
m (→{{header|AutoHotkey}}: Minor indentation and casing edit) |
||
Line 86: | Line 86: | ||
m = 10 |
m = 10 |
||
n = 10 |
n = 10 |
||
Loop, 10 |
|||
{ |
{ |
||
i := A_Index - 1 |
i := A_Index - 1 |
||
Loop, 10 |
|||
{ |
{ |
||
j := A_Index - 1 |
|||
%a%%i%%j% := i - j |
|||
} |
} |
||
} |
} |
||
Line 98: | Line 98: | ||
transpose("a", m, n) |
transpose("a", m, n) |
||
after := matrix_print("a", m, n) |
after := matrix_print("a", m, n) |
||
MsgBox % before . "`ntransposed:`n" . after |
|||
Return |
|||
return |
|||
transpose(a, m, n) |
transpose(a, m, n) |
||
{ |
{ |
||
Local i, j, row, matrix |
|||
Loop, % m |
|||
{ |
{ |
||
i := A_Index - 1 |
i := A_Index - 1 |
||
Loop, % n |
|||
{ |
{ |
||
j := A_Index - 1 |
|||
temp%i%%j% := %a%%j%%i% |
|||
} |
|||
} |
|||
} |
} |
||
⚫ | |||
{ |
|||
loop, % m |
|||
i := A_Index - 1 |
|||
{ |
|||
Loop, % n |
|||
⚫ | |||
{ |
{ |
||
j := A_Index - 1 |
|||
%a%%i%%j% := temp%i%%j% |
|||
} |
|||
} |
|||
} |
} |
||
} |
} |
||
matrix_print(a, m, n) |
matrix_print(a, m, n) |
||
{ |
{ |
||
Local i, j, row, matrix |
|||
Loop, % m |
|||
{ |
{ |
||
i := A_Index - 1 |
i := A_Index - 1 |
||
row := "" |
row := "" |
||
Loop, % n |
|||
{ |
{ |
||
j := A_Index - 1 |
|||
row .= %a%%i%%j% . "," |
|||
} |
|||
} |
|||
StringTrimRight, row, row, 1 |
|||
matrix .= row . "`n" |
|||
} |
} |
||
Return matrix |
|||
}</lang> |
}</lang> |
||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
{{works with|QuickBasic|4.5}} |
{{works with|QuickBasic|4.5}} |