题型:综合题 题类:模拟题 难易度:困难
浙江省十校联盟2018年3月适应性考试信息技术试卷
Const n = 10
Dim a (1 To n) As Integer ‘保存原始数据
Dim b(1 To n ) As Boolean ‘数组b用来标记相应的位置有没有找过
Private Sub Command1 _ Click ()
Dim i As Integer , sum As Integer , total As Integer
sum = 0: total = 1 ‘total 表不第几组
i = 1
List 2.Addltem “第”& Str (total) & “组”
Do While sum < n
Do While Not b (i)
List 2.Addltem a (i)
b(i) = True
sum = sum + 1
Loop
If sum < n Then
total = total + 1
List 2.Addltem “第” & Str ( total ) &■“组”
i = 1
Do While b(i) ‘该循环用来查找下一组的开始位置
Loop
End If
Loop
End Sub
Private Sub Form _ Load ()
Dim i As Integer
Randomize
For i = 1 To n ‘产生 n 个不一样的整数,范围为[ 1, n ]
a(i) = Int(Rnd * n ) + 1
Do While
a (i) = Int(Rnd * n ) + 1
Loop
Next i
For i = 1 To n
List1.Addltem a (i)
b (i) = False
Next i
End Sub
Function f(x As Integer , y As Integer ) As Boolean
‘该函数的功能:判断x和数组a中前y个数有没有重复,有重复返回值True,否则False
End Function
试题篮