题型:综合题 题类:模拟题 难易度:困难
浙江省2019年信息技术选考模拟试卷四
Dim a(1 To 25) As Integer '数组a用于存储1~100之内的素数
Function search(k As Integer) As Integer
i = 1 : j = 25
Do While i <= j
m =
If a(m) = k Then
search = m : Exit Function
ElseIf k < a(m) Then
j = m - 1
Else
i = m + 1
End If
Loop
search = 0
End Function
Private Sub Command1 Click() '生成素数事件过程
Dim i, j, k As Integer
List1.Clear
k = 0
For i = 2 To 100
For j = 2 To i - 1
If i Mod j = 0 Then
Exit For
End If
Next j
If Then
k = k + 1
a(k) = i
List1.AddItem "a(" & k & ")=" & a(k)
End If
Next i
End Sub
Private Sub Command2 Click() '查找数据事件过程
Dim t As Integer, r As Integer
t = Val(Text1.Text)
r =
If r = 0 Then
Label3.Caption = "1~100中的素数无此数据!"
Else
Label3.Caption = "素数序列和第" & Str(r) & "个数!"
End If
End Sub
试题篮