当前状态下下列说法不正确的是( )
t= false
i= 0
Do While i<7 And t= False
i=i+ 1
If a(i)= Key Then t= True
Loop
If t= False Then i=0
数组元素a(1)到a(7)的数据依次为“3,5,1,5,8,9,5”,当变量key值为5时,运用该算法处理后,变量i的值是( )
实现上述功能的VB程序如下,但加框处代码有错,请改正。
Const n = 10
Dim a(1 To n) As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer, t As Integer, bottom As Integer
'获取排序前数据依次存储在数组a 中,并在文本框Text1 中显示。代码略
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
ElseIf 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
⑴ ⑵
则下列说法正确的是( )
For i=1 To 6
a(i)=Int(Rnd*10)+1
Next i
For i=1 To 5
If i Mod 2=1 And a(i)>a(i+1)Then t=a(i):a(i)=a(i+1):a(i+1)=t a(i)=a(i)+1
End if
Next i
执行程序后,数据 a 中的各个元素可能是( )