vb 定义一个5×5二维数组 随机产生25个二位数存于此数组中,统计数组对
答案:1 悬赏:80 手机版
解决时间 2021-11-13 09:15
- 提问者网友:自食苦果
- 2021-11-12 17:50
vb 定义一个5×5二维数组 随机产生25个二位数存于此数组中,统计数组对
最佳答案
- 五星知识达人网友:大漠
- 2021-11-12 19:05
VB6新建一工程,在窗体上拖入一个命令按钮。然后进入代码区,删除所有代码后,粘贴以下代码即可:
1
Option Explicit
Private Sub Command1_Click()
Dim a(4, 4) As Long
Dim I As Long, J As Long
Dim K As Long, S1 As Long, S2 As Long
Randomize
Me.AutoRedraw = True
For I = 0 To 4
For J = 0 To 4
a(I, J) = Rnd() * 89 + 10
Print a(I, J),
If I = J Then S1 = S1 + a(I, J)
If I + J = 4 Then S2 = S2 + a(I, J)
Next J
Print
Next I
Print "对角线的值的平均值有两个。"
Print "从左上角到右下角:"; S1 / 5, "从右上角到左下角:"; S2 / 5
End Sub追问不是求平均值啊 是求奇数个数
就是怎么把两条对角线中重复的那个数去掉多算的那一次
1
Option Explicit
Private Sub Command1_Click()
Dim a(4, 4) As Long
Dim I As Long, J As Long
Dim K As Long, S1 As Long, S2 As Long
Randomize
Me.AutoRedraw = True
For I = 0 To 4
For J = 0 To 4
a(I, J) = Rnd() * 89 + 10
Print a(I, J),
If I = J Then S1 = S1 + a(I, J)
If I + J = 4 Then S2 = S2 + a(I, J)
Next J
Next I
Print "对角线的值的平均值有两个。"
Print "从左上角到右下角:"; S1 / 5, "从右上角到左下角:"; S2 / 5
End Sub追问不是求平均值啊 是求奇数个数
就是怎么把两条对角线中重复的那个数去掉多算的那一次
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯