[求助]求大侠帮我做两题“函数与过程”的题目
小弟初学VB 水平菜得一塌糊涂 下面两题实在做不出来了 望大侠们帮助
1。编制通用函数过程,计算double类型一维数组所有元素的平均值。
2。编制通用sub过程,将single类型一维数组反序排放(如实参数数组元素依次为6.5.9.7调用后为7.9.5.6;若为-3.2 ,4,2.6,31,7.3 调用后为7.3,31,2.6,4,-3.2)
尽量详细一点 谢谢了
1. const size = 1000
private function CalAvg(byval Array1(size) as double) as double
dim i as integer,total as double
total = 0
for i = 0 to size -1
total = total + array1(i)
next i
CalAvg = total/size
end function
2. private sub ReverseOrder (ByRef Array1(size) as single)
dim i as integer,tmp as single
for i = 0 to (size - 1)/2
tmp = array1(size - 1 - i)
array1(size - 1 - i) = array1(i)
array1(i) = tmp
next i
end sub