初中VB题 求答案
发布网友
发布时间:2022-10-13 01:26
我来回答
共3个回答
热心网友
时间:2023-10-26 07:51
s=0
p=50
q=100
For i = 1 To 20
a=Int(Rnd*51+50)
Print a;
if a>=p then
p=a
end if
if a<=q then
q=a
end if
s=s+a
Next i
b=s/20
print "最大值是";p
print "最小值是";q
print "平均值是";b
end sub
热心网友
时间:2023-10-26 07:51
Dim i, s, aver, max, min, a(20) As Integer
Print "这些数是:";
For i = 1 To 20
a(i) = Int(Rnd() * 50 + 51)
Print a(i);
s = s + a(i)
max = a(1)
min = a(1)
Next
Print
For i = 1 To 19
If min > a(i + 1) Then
min = a(i + 1)
End If
Next i
For i = 1 To 19
If max < a(i + 1) Then
max = a(i + 1)
End If
Next i
aver = s / 20
Print "最大是"; max
Print "最小是"; min
Print "平均是"; aver追问我们要的是自己画出来的啊,command1是选20个数,在text1里显示20个数。command2是最大值 command3是最小值,command4是平均值得,然后text2显示结果..请问这些框里分别该写什么啊?
热心网友
时间:2023-10-26 07:52
Private sub command1-click()
Dim i as integer,j as integer,a(20) as integer ,S as ingeder,max as integer ,min as integer
for i = 1 to 20
j=Int(Rnd*51)+50
a(i) = j
S=S+a(i)
next i
S=S/20
max=a(1):min=a(1)
for m=2 to 20
if a(m)<min then
min=a(m)
else if a(m)>max then
max=a(m)
End if
next it
Text1.Text=max
Text2.Text=min
End sub追问我们要的是自己画出来的啊,command1是选20个数,在text1里显示20个数。command2是最大值 command3是最小值,command4是平均值得,然后text2显示结果..请问这些框里分别该写什么啊?