VB中求二维数组各行各列元素之和
用VB编写程序,将随机产生的16个10到99范围内的随机整数存放在二维数组中,然后计算并输出各行及各列元素之和。谢谢啦!...
用VB编写程序,将随机产生的16个10到99范围内的随机整数存放在二维数组中,然后计算并输出各行及各列元素之和。谢谢啦!
展开
2个回答
展开全部
Private Sub Command1_Click()
Dim a(4, 4) As Double
Dim sum1 As Double
For i = 1 To 4
sum = 0
For j = 1 To 4
a(i, j) = Format(Rnd * 89 + 10, "0")
sum = sum + a(i, j)
Print a(i, j);
Next j
Print sum
Next i
For j = 1 To 4
sum = 0
For i = 1 To 4
sum = sum + a(i, j)
Next i
Print sum;
Next j
End Sub
连每樱斗瞎个数都输出了,你自己运销颤行脊空一下看看。
Dim a(4, 4) As Double
Dim sum1 As Double
For i = 1 To 4
sum = 0
For j = 1 To 4
a(i, j) = Format(Rnd * 89 + 10, "0")
sum = sum + a(i, j)
Print a(i, j);
Next j
Print sum
Next i
For j = 1 To 4
sum = 0
For i = 1 To 4
sum = sum + a(i, j)
Next i
Print sum;
Next j
End Sub
连每樱斗瞎个数都输出了,你自己运销颤行脊空一下看看。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_click()Dim a(4, 4) As Integer
Dim s(4) As Integer
Dim k(4) As Integer
Print
Print "森宏数组旅春渗元素:"
For i = 1 To 4
For j = 1 To 4
Randomize
a(i, j) = Int(Rnd * (100-10)+10)
Print Format(a(i, j), "@@@@");
Next j
Print
Next i
For i = 1 To 4For j = 1 To 4
s(i) = s(i) + a(i, j)
k(i) = k(i) + a(j, i)
Next j
Print "第" & i & "行拆脊之和:" & s(i) & " ";
Print "第" & i & "列之和:" & k(i)
Next i
End Sub
Dim s(4) As Integer
Dim k(4) As Integer
Print "森宏数组旅春渗元素:"
For i = 1 To 4
For j = 1 To 4
Randomize
a(i, j) = Int(Rnd * (100-10)+10)
Print Format(a(i, j), "@@@@");
Next j
Next i
For i = 1 To 4For j = 1 To 4
s(i) = s(i) + a(i, j)
k(i) = k(i) + a(j, i)
Next j
Print "第" & i & "行拆脊之和:" & s(i) & " ";
Print "第" & i & "列之和:" & k(i)
Next i
End Sub
参考资料: 《visual basic 实验与考级训练指导》主编:黎明 梅挺 许泽明 Page39
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询