...随机数程序,生成10个范围是1到100随机整数,并求出这10个数的最大值...
发布网友
发布时间:2024-10-22 16:27
我来回答
共2个回答
热心网友
时间:2024-10-25 02:17
'声明变量
dim Min_num as int
dim Max_num as int
dim Sum_num as int
dim Arr_num(9) as int
'赋予初始值
Min_num=101
Max_num=-1
Sum_num=0
'循环10次获得10个随机数
for i=1 to 10
randomize
Arr_num(i-1)=int(rnd*100)+1
'判断后赋值最小值
if Arr_num(i-1)<Min_num then Min_num=Arr_num(i-1)
'判断后赋值最大值
if Arr_num(i-1)>Max_num then Max_num=Arr_num(i-1)
'累计合计值,用于最后计算平均值
Sum_num=Sum_num+Arr_num(i-1)
next
msgbox ("最大值:" & cstr(Max_num) & vbcrlf & "最小值:" & cstr(Min_num) & vbcrlf & "平均数:" & cstr(cint(Sum_num)/10) & vbcrlf)
热心网友
时间:2024-10-25 02:19
好的话 给采纳不?