Private Sub Com 1_Click()
Dim m As integer, sum as integer, r as integer
Dim s as string
If Val(Text 1.Text) > 32767 then
Label 2.caption=“请重新输入1个不超过32767的正整数!”
Else
m=val(text 1.text) :sum=0:s=“”
Do while m> 0
r=m mod 2
sum=sum+r
①
Loop
Label 2.caption=”二进制数为:”+s
Label 3.caption=”二进制数中1的个数:”+ ②
End if
End sub
①
②
s=“491053”
For i=1 To 3
n=Len(s)
k=1
For j=2 To n
If Mid(s, k, 1) >=Mid(s, j, 1) Then
K=j
Else
Exit For .Exit For表示退出循环
End If
Next j
s= Mid(s, 1, k-1) + Mid(s, k+ 1,n-k)
Next i
Label1.Caption =s
执行该程序段后,标签Label1中显示的值是( )
Const n = 10
Dim a(1 To 10) As Integer
m = Int(Rnd * n + 1)
For i = 1 To 10
a(i) = 0
Next i
i = 0: j = 0: c = 1: ans = ""
Do While c <= 3
i = i Mod n + 1
If a(i) = 0 Then j = j + 1
If j = m Then
a(i) = 1: c = c + 1
j = 0: ans = ans + Str(i)
End If
Loop
Text1.Text = ans
执行上述程序段后,文本框Text1中不可能的内容是( )
请回答下列问题:
a(1)=55:a(2)=44:a(3)=11
a(4)=22:a(5)=33
For i = 1 To 2
For j = 1 To 4-i
If a(j)>a(j+1)Then
t=a(j):a(j)=a(j+1):a(j+1)=t
End If
Next j
Next i