a(1)=72:a(2)=78:a(3)=71:a(4)=82:a(5)=5:a(6)=41
n=6
For i=1 To n\ 2
k=i
For j=i To n- i
If a(j)>a(j+1)Then t=a(j):a(j)=a(j+1):a(j+1)=t
If a(j)<a(k) Then k=j
Next j
temp=a(k):a(k)=a(i):a(i)=temp
Next i
执行上述程序段后,数组元素a(1)到a(6)的值为( )
实现上述功能的VB程序如下,但加框处代码有错,请改正。
Const n = 10
Dim a(1 To n)As Integer
Private Sub Commandl_Click()
Dim i As Integer,j As Integer,t As Integer
Dim bottom As Integer
'获取排序前数据依次存储在数组a中,并在文本框Text 1中显示。代码略
bottom = n
i = 1
Do While i<= bottom-1
For j = bottom To i + 1 Step -1
If Then ‘⑴
t = a(j): a(j)= a(j - 1):a(j - 1)= t
Elself a(j)= a(j - 1)Then '相邻两个数据相等,进行剔除处理
‘⑵
bottom = bottom -1
End If
Next j
i = i+1
Loop
Text2.Text=""
For i = 1 To bottom
Text2.Text = Text2.Text+Str(a(i))
Next i
End Sub
⑴ ⑵
下列说法正确的是( )
①密码是六位数字,前面两位为59;
②最后两位数字相同;
③能被12和38整除。
程序界面如图1所示,单击 “帮助找回密码”按钮(Command1)后,可能的密码显示在列表框List1中。
Private Sub Command1_click ( )
Dim x As Integer, s As Long, y As Integer, i As Integer
For i = 0 To 9999
S = 590000 + i
If Then
x= s mod 10
y = (s Mod 100) \ 10
If x = y Then
List1.AddItem Str(s)
End If
End If
Next i
End Sub