题型:综合题 题类:常考题 难易度:普通
【bj】高中信息技术综合库——枚举算法及程序实现2
密码强度判断条件如下:密码长度小于6,则强度为“弱”。在密码长度大于等于6的情况下,若只出现一种字符,则密码强度为“弱”;若出现两种不同字符,则密码强度为“中”,出现三种以上不同字符,则密码强度为“强”。
Private Sub Cmd1_Click()
Dim n As Integer, i As Integer, m As Integer, s As String, c As String
If n<6 Then
Label3.Caption="弱"
Else
s="0000"
For i=1 To n
c=Mid(Text1.Text, i, 1)
If c>="0" And c<="9" Then
Mid(s, 4, 1)="1" '将字符串s第4位上的字符替换为"1"
ElseIf c>="A" And c<="Z" Then
Mid(s, 3, 1)="1"
ElseIf c>="a" And c<="z" Then
Else
Mid(s, 1, 1)="1"
End If
Next i
m=0
For i=1 To 4
If Mid(s, i, 1)="1" Then
Next i
If m<2 Then
Label 3.Caption="弱"
ElseIf m=2 Then
Label 3.Caption="中"
Else
Label3.Caption="强"
End If
End If
End Sub
依据上述描述设计如下VB程序:
Dim xh(1 To 100) As Integer , xm(1 To 100) As String, cj(1 To 100) As Integer Dim n As Integer, m As Integer
Private Sub Form_Load()
'本过程从数据库依次读取n位同学的序号、姓名及成绩,然后按成绩降序排序,将学生序号、姓名成绩存储在数组xh、xm、cj中,结果显示在List1中,
End Sub
'显示每位同学的位置 Private Sub Command1_Click() Dim wz As String m=Val(Text1.Text) For i = 1 To n \ m For j = 1 To m If ① Then wz = wz + xm((i - 1) * m + j) + " " Else wz=xm((i-1) * m + j)+" "+wz End If Next j List2.AddItem wz wz =" " Next i If n Mod m <> 0 Then For i= To n ‘加框处改错 wz = wz + xm(i) + " " Next i List2.AddItem wz End If End Sub |
'显示每位同学的位置编号 Private Sub Command2_Click() Dim zu As Integer Dim ha As String, hb As String List3.AddItem "序号" & vbTab & "姓名" & vbTab & "位置" 'vbTab 用于字符对齐 For i = 1 To n zu = ② ha = Trim(str(zu)) If Len(ha) = 1 Then ha = "0" + ha If zu Mod 2 = 0 And zu <= n \ m Then hb = ③ Else hb = Str(i - m * (zu - 1)) End If hb = Trim(str(hb)) 'Trim 函数功能是去除字符空格 If Len(hb) = 1 Then hb = "0" + hb List3.AddItem str(i) & vbTab & xm(i) & vbTab+ ha + hb Next i End Sub |
请回答下列问题:
试题篮