(單選,填字母:A.Form1/B.Text1/C.Label1) (2)實現(xiàn)上述功能的 VB 程序如下,請在橫線處填入合適代碼。 (3)程序代碼中的加框處代碼有誤,請改正。 Dim n As Integer Dim a(1 To 100)As Integer Private Sub create_Click ( ?。?br />Dim i As Integer Randomize n=Val(Text1.Text) For i=1 To n a(i)=Int(Rnd ( ?。?45)*2+11 If ①
i Mod 2=0
i Mod 2=0
Then a(i)=a(i)-1 List1.AddItem Str(a(i)) Next i End Sub Private Sub sort_Click ( ?。?br />For i=1 To n\2 For j=1 To n-2*i Step 2 If ②
a(j)>a(j+2)
a(j)>a(j+2)
Then t=a(j):a(j)=a(j+2):a(j+2)=t End If Next j k=c For j=k+2 To n Step 2 If a(j)>a(k)Then ③
k=j
k=j
Next j If k<>c Then t=a(k):a(k)=a(c):a(c)=t End If Next i For i=1 To n List2.AddItem Str(a(i)) Next i End Sub
1.大部分社交軟件都有好友推薦的功能,當用戶 A 和用戶 B 的共同好友數(shù)量超過閾值 p 時,由系統(tǒng)向用戶 A 推薦用戶 B。 編寫 VB 程序,實現(xiàn)好友推薦功能。運行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標用戶 id,在文本框 Text2 中輸入閾值 p,點擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關(guān)系,在標簽 Label5 中顯示向目標用戶推薦的好友列表。程序運行界面如圖: (1)根據(jù)如圖所示數(shù)據(jù),若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: