(單選,填字母) A.List1.Clear/B.List1.List=““/C.List1.Text=““/D.List1.Caption=“空白“)。 (2)實現分段排序功能的VB程序如下,請在橫線處填入合適的代碼。 (3)程序中代碼有錯,請改正。 Dim a(1 To 1000)As Integer Dim n As Integer Private Sub Command1_Click ( ) '輸入數據總量n,隨機生成n個數據保存在數組 'a(1)~a(n)中,并在List1中顯示數據,代碼略 End Sub Private Sub Command2_Click ( ) Dim b(1 To 10000)As Integer Dim p1 As Integer,p2 As Integer,t1 As Integer,t2 As Integer Dim t As Integer,k As Integer,i As Integer,j As Integer p1=1 t1=leng(p1) p2=p1+t1 Do While p2<=n ①
t2=leng(p2)或t2=leng(t1+p1)或t2=leng(t1+1)
t2=leng(p2)或t2=leng(t1+p1)或t2=leng(t1+1)
i=p1:j=p2:t=1 Do While i<p2 Or j<p2+t2 If j>=p2+t2 Or i<p2 And a(i)<a(j) Then b(t)=a(i):i=i+1 Else b(t)=a(j):j=j+1 End If t=t+1 Loop For k=1 To ②
1+t2或t-1或p2+t2-1
1+t2或t-1或p2+t2-1
a(k)=b(k) Next k t1=t1+t2 p2=p1+p2 Loop '在List2中輸出數組a(i)的值,代碼略 End Sub Function Leng(ByVal p As Integer) As Integer '該函數返回數組a中數組下標p開始的升序有序段的長度,代碼略 End Function
1.大部分社交軟件都有好友推薦的功能,當用戶 A 和用戶 B 的共同好友數量超過閾值 p 時,由系統向用戶 A 推薦用戶 B。 編寫 VB 程序,實現好友推薦功能。運行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標用戶 id,在文本框 Text2 中輸入閾值 p,點擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關系,在標簽 Label5 中顯示向目標用戶推薦的好友列表。程序運行界面如圖: (1)根據如圖所示數據,若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: