內容 :
已知一(m x n)矩陣A,我們常常需要用到另一個將A中之行與列調換的矩陣。這個動作叫做矩陣的翻轉。舉例來說,若
現在 請您針對所讀取到的矩陣進行翻轉。
A = [ 3 1 2 ] 8 5 4
則
AT = [ 3 8 ] 1 5 2 4
現在 請您針對所讀取到的矩陣進行翻轉。
輸入說明 :
第一行會有兩個數字,分別為 列(row)<100 和 行(column)<100,緊接著就是這個矩陣的內容
輸出說明 :
直接輸出翻轉後的矩陣
範例輸入 :
2 3
3 1 2
8 5 4
範例輸出 :
3 8
1 5
2 4
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x, y
ReDim aa(y) As String
For i = 1 To x
For j = 1 To y
Input #1, step
aa(j) = aa(j) & " " & step
Next j
Next i
For i = 1 To y
Print #2, aa(i)
Next i
Close #2
Close #1
End Sub
BY 阿揚
Dim Row As Integer, Col As Integer
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, Row, Col
ReDim A(Col) As String
For i = 1 To Row
Line Input #1, St
x = Split(St)
For j = 0 To Col - 1
A(j + 1) = A(j + 1) & " " & x(j)
Next j
Next i
For i = 1 To Col
Print #2, A(i)
Next i
Close #2
Close #1
End
End Sub
BY 小白
矩陣的翻轉,是要將a(x,y) --->a(y,x)。
回覆刪除再試試吧。