题型:综合题 题类:常考题 难易度:普通
浙江省高中信息技术 枚举算法及程序实现同步练习
Const n=12
Dim a(1 To n) As Integer
Dim flag(1 To 100) As Boolean
Private Sub Form_Load()
Dim i As Integer, t As Integer
For i=1 To 100
flag(i)=False
Next i
i=1
Do While i <=n
t=Int(Rnd * 100)+1
If Not flag(t) Then
List1.AddItem Str(t)
flag(t)=True
i=i+1
End If
Loop
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, ans As Integer
ans=0
For i=1 To n
For j=i+1 To n
If a(i)+a(j) <=100 Then
IfThen
ans=ans+1
flag(a(i)+a(j))=False
End If
Next j
Next i
Label1.Caption="共有"+Str(ans)+"个数!"
End Sub
①共八位字符,前两位为字母“zj”,后六位是数字,并以66开头(即密码格式为zj66****);
②最后两位数字相同;
③后六位数能被16和46同时整除。
单击“找回密码”按钮(Command1)后,可能的密码显示在列表框List1中。
|
Private Sub Command1Click()
Dim s As Long , a As Integer, b As Integer, c As Integer, i As Integer
For i = 0 To 9999
s = 660000 + i
If ① And s Mod 46 = 0 Then
'(选填字母,从下列A、B 、C、D四个选项中选取一项)
a = s Mod 10
b = (s Mod 100) \ 10
If ② Then '(选填字母,从下列A、B 、C、D四个选项中选取一项)
List1.AddItem ("zj" + Str(s))
c = ③ '(填程序代码)
End If
End If
Next i
Label1.Caption = "共有" + Str(c) + "个"
End Sub
试题篮