vb以两个二重循环为5行5列数组赋值如下,然后按行列关系显示该数组
4个回答
展开全部
Private Sub Command1_Click()
Dim a(5, 5), m, n
For i = 1 To 5
m = 7 - i
n = -1
For j = 1 To 5
m = m + n
If m = 0 Then n = -n: m = 2
a(j, i) = m
Next j, i
For i = 1 To 5
For j = 1 To 5
Print a(i, j);
Next j
Print
Next i
End Sub
Dim a(5, 5), m, n
For i = 1 To 5
m = 7 - i
n = -1
For j = 1 To 5
m = m + n
If m = 0 Then n = -n: m = 2
a(j, i) = m
Next j, i
For i = 1 To 5
For j = 1 To 5
Print a(i, j);
Next j
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n As Integer
Dim d(1 To 5, 1 To 5) As Integer
For i = 1 To 5
n = 6 - i
k = 0
Do While n > 0
k = k + 1
d(i, k) = n
n = n - 1
Loop
n = 1
Do While k <= 5
d(i, k) = n
n = n + 1
k = k + 1
Loop
Next i
For i = 1 To 5
For j = 1 To 5
Print d(i, j);
Next j
Print
Next i
Dim j As Integer
Dim k As Integer
Dim n As Integer
Dim d(1 To 5, 1 To 5) As Integer
For i = 1 To 5
n = 6 - i
k = 0
Do While n > 0
k = k + 1
d(i, k) = n
n = n - 1
Loop
n = 1
Do While k <= 5
d(i, k) = n
n = n + 1
k = k + 1
Loop
Next i
For i = 1 To 5
For j = 1 To 5
Print d(i, j);
Next j
Next i
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一楼和二楼的程序都不错,但是在打印数组的时候不需要再用循环了,
只需要 range(“a1,:e5”)=“数组名” 就可以了
只需要 range(“a1,:e5”)=“数组名” 就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要求说明白点,怎么显示? 行列关系?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询