题库 高中信息

题干

下列VB程序段的功能为:生成n个不重复的随机整数,保存在数组a中,并升序排序。
Const n = 6
Dim a(1 To n) As Integer, f(1 To 10) As Boolean
Dim tmp As Integer, i As Integer, j As Integer, t As Integer
’f数组各元素的初值置为False,代码略
For i = 1 To    (1)  
t = Int(1 + Rnd * 10)
If Not f(t) Then
a(i) = t : f(t) = True
For j = (2)   
If a(j) < a(j - 1) Then
tmp = a(j): a(j) = a(j - 1): a(j - 1) = tmp
End If
Next j
Else
(3)  
End If
Next i
上述程序段3个方框处的表达式分别为
A.(1)n - 1 (2)2 to i    (3)i = i - 1
B.(1)n (2)i to 2 Step -1    (3)i = i - 1
C.(1)n - 1    (2)2 to i    (3)t = Int(1 + Rnd * 10)
D.(1)n (2)i to 2 Step -1    (3)t = Int(1 + Rnd * 10)
上一题 下一题 0.99难度 选择题 更新时间:2019-05-25 01:13:55

答案(点此获取答案解析)