VB 编写程序“生成”时随机产生25个小于100的整数保存到一个二维数组中,打印到图片框中。
1个回答
展开全部
是不是5×5的数组?如果是的话代码如下
Private Sub Command1_Click()
Dim a(4, 4), x As Integer, y As Integer, m As Integer, n
Randomize
For x = 0 To 4
For y = 0 To 4
a(x, y) = Int(Rnd * 100)
Picture1.Print a(x, y);
Next
Picture1.Print
Next
m = a(0, 0) + a(0, 4) + a(1, 1) + a(1, 3) + a(2, 2) + a(3, 1) + a(3, 3) + a(4, 0) + a(4, 4)
n = a(0, 0) * a(0, 4) * a(1, 1) * a(1, 3) * a(2, 2) * a(3, 1) * a(3, 3) * a(4, 0) * a(4, 4)
MsgBox "和=" & m & vbCrLf & "积=" & n
End Sub
可以用的
Private Sub Command1_Click()
Dim a(4, 4), x As Integer, y As Integer, m As Integer, n
Randomize
For x = 0 To 4
For y = 0 To 4
a(x, y) = Int(Rnd * 100)
Picture1.Print a(x, y);
Next
Picture1.Print
Next
m = a(0, 0) + a(0, 4) + a(1, 1) + a(1, 3) + a(2, 2) + a(3, 1) + a(3, 3) + a(4, 0) + a(4, 4)
n = a(0, 0) * a(0, 4) * a(1, 1) * a(1, 3) * a(2, 2) * a(3, 1) * a(3, 3) * a(4, 0) * a(4, 4)
MsgBox "和=" & m & vbCrLf & "积=" & n
End Sub
可以用的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询