怎样用qbasic求一组数据的众数
qbasic吧
全部回复
仅看楼主
level 1
hjq447285628 楼主
自学qbasic没几天,还有很多不会,过来问一下怎样用qbasic求一组数据的众数
众数即一组数据出现次数最多的数,可能有一个,可能有多个,要求如果有多个要都显示出来
还有数据的个数以及每个数据都要用户自己输入
2010年02月02日 11点02分 1
level 0
cls
input n
dim a(n),b(n)
for i=1 to n
   input a(i)
next i
x=0
for i=1 to n
for j=i+1 to n
    if b(j)=999999 then exit for
    if a(i)=a(j) then b(i)=b(i)+1:b(j)=999999
   next j
if b(j)>x then x=b(i)
next i
for i=1 to n
if b(i)=x then print a(i),
next i
2010年02月08日 02点02分 2
level 1
hjq447285628 楼主
回复:2楼
exit for 是什么意思?
如果方便的话,加一些注释好吗
2010年02月09日 10点02分 3
1