(單選,填字母:A.冒泡排序/B.選擇排序/C.順序查找/D.對(duì)分查找)。 Dim n As Integer Dim d(1 To 100)As Integer'數(shù)組 d 存儲(chǔ)待排序數(shù)據(jù) Private Sub Command1_Click ( ?。?br />'按旋轉(zhuǎn)數(shù)組規(guī)則將數(shù)據(jù)存入數(shù)組d中,代碼略 End Sub Private Sub Command2_Click ( ) Dim mid As Integer,L As Integer,R As Integer L=1:R=n mid=L Do While d(L)>=d(R) If Then'改錯(cuò) mid=R Exit Do End If mid=(L+R)\2 If d(L)=d(R) And d(mid)=d(R) Then mid=
'填空 Exit Do End If If d(L)<d(mid) Then L=mid ElseIf d(mid)<d(R) Then R=mid End If Loop Label2.Caption=“最小值為“+Str(d(mid)) End Sub
。 (2)請(qǐng)?jiān)跈M線處填入合適的代碼。 Dim a(20)As Integer Const n=20 Private Sub Form_Load ( ?。?br />'隨機(jī)產(chǎn)生n個(gè)[1,100]之間的隨機(jī)整數(shù),依次存儲(chǔ)到a(1)、a(2)、…a(n)中,并在文本框Text1顯示,代碼略 End Sub Private Sub Command1_Click ( ?。?br />Dim i As Integer,p As Integer,k As Integer,cnt As Integer,c As Integer,t As Integer p=Val(Text2.Text) k=Val(Text3.Text) i=1:start=1:c=a(i):cnt=1 Do While cnt<=p'方法二 i= ① t=a(i) a(i)=c If ② Then start=start+1 i=i+1 c=a(i) Else c=t End If cnt=cnt+1 Loop For i=1 To k'方法一 temp=a(n) For j= ③ a(j)=a(j-1) Next j a(p+1)=temp Next i For i=1 To n s=s+Str(a(i)) Next i Text4.Text=s End Sub