vb编程的问题,求解答。。。。谢谢了。定义一个10*10的二维整型数组,产生100个随机数保存在数组中,编写
定义一个10*10的二维整型数组,产生100个随机数保存在数组中,编写程序求二维数组的上三角之和与下三角之和的差(不包括主对角线上的元素)。...
定义一个10*10的二维整型数组,产生100个随机数保存在数组中,编写程序求二维数组的上三角之和与下三角之和的差(不包括主对角线上的元素)。
展开
2个回答
展开全部
Private Sub Command1_Click()
Dim a(1 To 10, 1 To 10) As Integer, ssj As Long, xsj As Long
Cls
Randomize
For i = 1 To 10
For j = 1 To 10
a(i, j) = Int(Rnd * 90 + 10)
Print a(i, j);
Next j
Next i
For i = 1 To 10
For j = i + 1 To 10
ssj = ssj + a(i, j)
xsj = xsj + a(j, i)
Next j
Next i
Print "上三角和为:"; ssj
Print "下三角和为:"; xsj
Print "上、下三角和之差为:"; ssj - xsj
End Sub
展开全部
生成数组 天字第一号就不写了 假设你的数组叫 Arr()
dim ShangSanJiao aa long
dim XiaSanJiao as long
dim i as long
dim J as long
for i=9 to 1 step -1
for j=i to to 1 step -1
ShangSanJiao= ShangSanJiao+arr(i,j)
next
next
for i=2 to 10 step -1
for j=i to to 10
XiaSanJiao = XiaSanJiao +arr(i,j)
next
next
dim ShangSanJiao aa long
dim XiaSanJiao as long
dim i as long
dim J as long
for i=9 to 1 step -1
for j=i to to 1 step -1
ShangSanJiao= ShangSanJiao+arr(i,j)
next
next
for i=2 to 10 step -1
for j=i to to 10
XiaSanJiao = XiaSanJiao +arr(i,j)
next
next
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询