题型:综合题 题类:常考题 难易度:普通
浙江省嘉兴市2020-2021学年高二上学期信息技术期末检测卷
如:输入十进制数35,将其转换为二进制数为100011,其中最长连续数字是3个“0”。程序运行界面如图所示。
Private Sub Command1_Click()
Dim n As Integer, i As Integer, j As Integer, m As Integer
Dim s As String, ch As String, ch1 As String, ch2 As String
n = Val (Text1. Text)
Do While n<>0
s=CStr(n Mod 2)+s ‘CStr将数字转化为字符串,但不会有前导空格
Loop
ch1 = Mid(s, 1, 1): ch = ch1
i=2:j=1:m=0
For i=2 To Len(s)
ch2 = Mid(s, i, 1)
If Then
If i-j> m Then
m=i-j
ch = ch1
End If
ch1 = ch2
End If
Next i
Text2. Text = Str(m) & “个”& ch
End Sub
试题篮