VB.用随机函数产生100个【0,99】范围内的随机整数,统计个位上的数字为0,1,2..9的元素个数(使用数组

beiqiu 1年前 已收到1个回答 举报

baggioshixiao 春芽

共回答了18个问题采纳率:94.4% 举报

dim a(99) as integer
dim i as integer
dim sums(9) as integer
dim index as integer
Randomize
for i=0 to 99
a(i)=int(100*rnd)
index=a(i) mod 10
sums(index)=sums(index) +1
next i
for i =0 to 9
print i "的个数是:" sums(i)
next

1年前

9
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 1.829 s. - webmaster@yulucn.com