VB.用随机函数产生100个【0,99】范围内的随机整数,统计个位上的数字为0,1,2..9的元素个数(使用数组
问题描述:
VB.用随机函数产生100个【0,99】范围内的随机整数,统计个位上的数字为0,1,2..9的元素个数(使用数组
答
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