English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

轉置陣列是將陣列的形變成陣,列變成行.若有二維陣列a[][]={{7,8},{9,10}{11,12}},寫一程式求此陣列的轉置陣列...

2007-01-05 14:58:55 · 1 個解答 · 發問者 小黑蓁 2 in 電腦與網際網路 程式設計

我是要用java的

2007-01-06 08:41:48 · update #1

1 個解答

這是獨立的程式
可以直接呼叫
m, n 可以自己改
目前是由電腦隨機給值
Public Sub Tarray()
Dim i As Integer, j As Integer, m As Integer, n As Integer
Dim a(10, 10) As Integer, b(10, 10) As Integer
Dim buf As String
m = 6: n = 2 ' m <= 10, n <= 10
Randomize
For i = 1 To m
buf = ""
For j = 1 To n
a(i, j) = Int(Rnd() * 50) + 1 ' 1 ~ 50
buf = buf & Format(a(i, j), "@@@")
Next j
Print buf
Next i
For i = 1 To m
For j = 1 To n
b(j, i) = a(i, j)
Next j
Next i
For i = 1 To n
buf = ""
For j = 1 To m
buf = buf & Format(b(i, j), "@@@")
Next j
Print buf
Next i
End Sub
如果有問題, 請來函討論. 不然, 我可能會錯失你再補充的疑點.

2007-01-06 08:25:37 · answer #1 · answered by JJ 7 · 0 0

fedest.com, questions and answers