将一个包含10位学生成绩的数组平均分数从大到小排序,然后显示排序结果

For i = 1 To 9
For j = i + 1 To 10
If a(i) > a(j) Then k = a(i): a(i) = a(j): a(j) = k
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
把这个直接打上去为什么提示缺少子程序或函数未定义??

你说把这个直接打上去是不是没有定义数组??
另外,你用的冒泡排序法貌似有点问题……
Private Sub Command1_Click()
Dim a%(1 To 10)
Randomize
For i = 1 To 10
a(i) = Int(Rnd * 101) '随机产生0到100的整数
Next i

For i = 10 To 1 Step -1 '冒泡排序法
For j = 1 To i - 1
If a(j) > a(j + 1) Then k = a(j): a(j) = a(j + 1): a(j + 1) = k
Next j
Next i

For i = 1 To 10
Print a(i);
Next i
End Sub
温馨提示:答案为网友推荐,仅供参考
相似回答