求解一道VB程序设计题:定义一个二维数组a,共4行4列。要求如下。

求解一道VB程序设计题:定义一个二维数组a,共4行4列。要求:(1)用随机函数产生[50,100]范围内的随机整数,并赋值给数组元素,并把改数组以4行4列的形式显示在窗体... 求解一道VB程序设计题:定义一个二维数组a,共4行4列。要求:(1)用随机函数产生[50,100]范围内的随机整数,并赋值给数组元素,并把改数组以4行4列的形式显示在窗体上。(2)求出数组的最大值max,最小值min,以及它们所对应的下标,并显示在窗体上。(3)求出数组元素的总和sum、平均值ave,并显示在窗体上。 展开
 我来答
我们的梦168
推荐于2017-09-28 · TA获得超过194个赞
知道小有建树答主
回答量:261
采纳率:0%
帮助的人:169万
展开全部
Private Sub Command1_Click()
Dim abc(3, 3) As Integer
Dim abcMax As Integer
Dim abcMin As Integer
Dim i As Integer
Dim j As Integer
Dim iMax As Integer
Dim jMax As Integer
Dim iMin As Integer
Dim jMin As Integer
Dim abcSum As Integer
Dim abcAve As Single
For i = 0 To 3
For j = 0 To 3
abc(i, j) = 50 + Int(Rnd(1) * 50)
Next j
Next i
abcMax = 0
abcMin = 100
For i = 0 To 3
For j = 0 To 3
If abc(i, j) > abcMax Then
abcMax = abc(i, j)
iMax = i
jMax = j
End If

If abc(i, j) < abcMin Then
abcMin = abc(i, j)
iMin = i
jMin = j
End If
Next j
Next i
abcSum = 0
For i = 0 To 3
For j = 0 To 3
abcSum = abcSum + abc(i, j)
Next j
Next i
abcAve = abcSum / 16
Me.FontSize = 20
For i = 0 To 3
For j = 0 To 3
Me.Print abc(i, j),
Next j
Me.Print
Next i
Me.Print "Max", iMax, jMax, abcMax
Me.Print "Min", iMin, jMin, abcMin
Me.Print "Sum", abcSum
Me.Print "Ave", abcAve
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
laolaibibulai
2014-06-27 · TA获得超过358个赞
知道小有建树答主
回答量:225
采纳率:0%
帮助的人:229万
展开全部
Private Sub Command1_Click()
Dim x(3, 3) As Integer
For i = 0 To 3
For j = 0 To 3
x(i, j) = 50 + Int(Rnd() * 51)
Next j
Next i
Cls
For i = 0 To 3
For j = 0 To 3
Print x(i, j),
Next j
Print
Next i
'------------------
Max = x(0, 0)
pmxi = 0
pmxj = 0
'------------------
Min = x(0, 0)
pnxi = 0
pnxj = 0
Sum = 0
For i = 0 To 3
For j = 0 To 3
Sum = Sum + x(i, j)
If x(i, j) > Max Then
Max = x(i, j)
pmxi = i
pmxj = j
End If
Next j
Print
Next i
For i = 0 To 3
For j = 0 To 3
If x(i, j) < Min Then
Min = x(i, j)
pnxi = i
pnxj = j
End If
Next j
Print
Next i
Print Max, pmxi, pmxj
Print Min, pnxi, pnxj
Print Sum, Sum / 16
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式