如何设置下面这种函数

来源:百度知道 编辑:UC知道 时间:2024/05/08 16:13:11
数字 23 24 25 23 65 45 24 56 56 58 15 68 21
找出 大于20小于30 大于30小于50 的数各有多少?

VB:

dim strs1,strs2,i,cnt1,cnt2
strs1="23,24,25,23,65,45,24,56,56,58,15,68 21"
strs2=split(strs1,",")

for i=0 to ubound(strs2)
if cint(strs2(i))>20 and cint(strs2(i))<30
cnt1=cnt1+1
end if

if cint(strs2(i))>30 and cint(strs2(i))<50
cnt2=cnt2+1
end if
next

response.write "大于20小于30的数有"&cnt1&”个”
response.write "大于30小于50的数有"&cnt2&”个”

sub finder()
dim a(12)
a(0)=23:a(1)=24:a(2)=25
a(3)=23:a(4)=65:a(5)=45
a(6)=24:a(7)=56:a(8)=56
a(9)=58:a(10)=15:a(11)=68:a(12)=21
h=0:k=0
for i=0 to 12
if a(i)>20 and a(i)<30 then
h=h+1
end if
if a(i)>30 and a(i)<50 then
k=k+1
end if
msgbox "大于20小于30的数有"&cstr(h)&"个"
msgbox "大于30小于50的数有"&cstr(k)&"个"
next