VB随机产生一个M×N二维数组(M,N缺省为4,数组元素为100以内的正整数),计算其

问题描述:

VB随机产生一个M×N二维数组(M,N缺省为4,数组元素为100以内的正整数),计算其
随机产生一个M×N二维数组(M,N缺省为4,数组元素为100以内的正整数),计算其所有元素中0-9出现的次数.

一下代码!你参考一下!
Private Sub Command1_Click()
Cls
Dim a() As Integer '定义一个动态数组
Dim b(10) As Integer '用于统计
Randomize
n = 4:m = 4
ReDim a(m,n) '重定义数组
For i = 1 To m
For j = 1 To n
a(i,j) = Rnd * 100 '赋值
Print a(i,j);
Next
Print
Next
For i = 1 To m
For j = 1 To n
For t = 0 To 9 '数组元素中查找0~9的数字
If a(i,j) = t Then b(t) = b(t) + 1
Next
Next
Next
For i = 0 To 9
Print m; "*"; n; "的数组中"; i; "出现"; b(i); "次"
Next
End Sub