VB 把一个m行n列矩阵中的元素存放到一个二维数组中,并求出该数组的平均值,最大值和最小值

求代码啊,能直接运行最好……

'创建数组
dim d() as integer
dim i as Integer
dim j as integer
dim m as integer
dim n as integer
dim x as integer
m=4 '设4行
n=3 '设3列
redim d(m,n) as integer
x=1
for i=1 to m
for j=1 to n
d(i,j)=x
x=x + 1
next j
next i

'求平均值,最大值,最小值
dim MyAve as single
dim MyMax as integer
dim MyMin as integer
dim t as integer
t=0
MyMax = d(1,1)
MyMin = d(1,1)
for i=1 to m
for j=1 to n
t=t + d(i,j)
if d(i,j)>MyMax then MyMax = d(i,j)
if d(i,j)<MyMin then MyMin = d(i,j)
next j
next i
print "平均值:" & t/(m*n)
print "最大值:" & MyMax
print "最小值:" & MyMin
温馨提示:答案为网友推荐,仅供参考