。 (2)實現(xiàn)上述功能的VB代碼如下,請在橫線處填入合適的代碼。 Private Sub Cmd1_Click ( ?。?br />Dim s As String,c As String Dim flag As Boolean Dim i As Integer,count As Integer s=Text1.Text flag=True For i=1 To Len(s)-1 c=Mid(s,i,2) If c=″**″Then ① Exit For End If Next i s=″#″+s+″#″ count=0:i=2 Do While flag And i<=Len(s)-1 If② Then s=Mid(s,1,i-1)+″*″+Mid(s,i+1,Len(s)-i) ③ End If i=i+1 Loop If Not flag Then Label2.Caption=″警告!″ ElseIf count=0 Then Label2.Caption=″該排人數(shù)已滿″ Else Label2.Caption=″該排至多還能有″+Str(count)+″個人入座″ End If End Sub
1.大部分社交軟件都有好友推薦的功能,當(dāng)用戶 A 和用戶 B 的共同好友數(shù)量超過閾值 p 時,由系統(tǒng)向用戶 A 推薦用戶 B。 編寫 VB 程序,實現(xiàn)好友推薦功能。運行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標(biāo)用戶 id,在文本框 Text2 中輸入閾值 p,點擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關(guān)系,在標(biāo)簽 Label5 中顯示向目標(biāo)用戶推薦的好友列表。程序運行界面如圖: (1)根據(jù)如圖所示數(shù)據(jù),若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: