题型:综合题 题类:常考题 难易度:困难
浙江省台州中学2014-2015学年高一下学期信息技术期中考试试卷
①密码是六位数字,前面两位为31;
②最后两位数字相同;
③能被16和46整除。
程序界面如下图所示,单击 "帮助找回密码"按钮(Command1),可能的密码显示在列表框List1中。
解决此问题的相应程序如下:
Private Sub Command1_Click()
Dim a As Integer, s As long, b As Integer, i As Integer
For i = 0 To ①
s = 310000 + i
If s Mod 46 = 0 And s Mod 16 = 0 Then
②
b = (s Mod 100) \ 10
If a = b Then
List1.AddItem Str(s)
End If
End If
Next i
End Sub
程序代码如下:
Private Sub Command1_Click()
Dim i As Integer
List1.Clear '清除列表框内容
For i = 3 To 97 ___①___ If f(i) And f(i+2)=true Then List1.AddItem Str(i) + " 和 " + Str(i + 2) End If Next i |
End Sub
Private Function f(x As Integer) As Boolean '判断是否为素数,若是返回true,若不是则返回false
………
End Function
试题篮