用VB编写一过程,实现一个二维数组的转置。(数组作为参数)

 我来答
听不清啊
高粉答主

2015-12-31 · 说的都是干货,快来关注
知道顶级答主
回答量:7.8万
采纳率:89%
帮助的人:1.9亿
展开全部

Private Sub Command1_Click()

  Dim a(1 To 3, 1 To 5) As Integer, b(1 To 5, 1 To 3) As Integer

  Cls

  Print "产生的A数组:"

  For i = 1 To 3

    For j = 1 To 5

      a(i, j) = Int(Rnd * 100)

      Print a(i, j);

    Next j

    Print

  Next i

  zhuanzhi a, b

  Print

  Print "转置后的B数组:"

  For i = 1 To 5

    For j = 1 To 3

      Print b(i, j);

    Next j

    Print

  Next i

  

End Sub


Sub zhuanzhi(ByRef a() As Integer, ByRef b() As Integer)

For i = LBound(a, 1) To UBound(a, 1)

    For j = LBound(a, 2) To UBound(a, 2)

        b(j, i) = a(i, j)

    Next j

Next i

End Sub

匿名用户
2013-07-07
展开全部
Private Sub Command1_Click()
Dim a(1, 2) As Integer
Dim b(2, 1) As Integer
Dim i As Integer
Dim j As Integer

For i = 0 To 1
For j = 0 To 2
a(i, j) = i * 3 + j
Print a(i, j);
Next
Print
Next
Print
Trans a, 2, 3, b
For i = 0 To 2
For j = 0 To 1
Print b(i, j);
Next
Print
Next
Print
End Sub

Private Sub Trans(a() As Integer, m As Integer, n As Integer, b() As Integer)
Dim i As Integer
Dim j As Integer

For i = 0 To n - 1
For j = 0 To m - 1
b(i, j) = a(j, i)
Next
Next
End Sub
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2013-07-07
展开全部
转置后是放在同1个数组还是放在另1个数组?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式