(3)實現隊形編排功能的VB程序如下,請在橫線處填入合適的代碼。 Private Sub Command 1_Click
( )
( )
Dim i As Integer,j As Integer Dim cnt As Integer,nAs Integer,tmp As Integer Dim kw As String,zw As String,c As String List 1.Clear cnt=Val(Text 1-Text) n=0:tmp=1 Do While cnt-tmp>0計算三角隊形的行數(*) cnt=cnt-tmp tmp=tmp+2 n=n+1 Loop For i=1 T on kw=“”:zw=“” For j=i T on-1 kw=kw+“” Next j If i=n The nc=“▲”Else c=“●” For j=1 To 2*(i-1)-1 zw=zw+c Next j If
i=1
i=1
Then ZW=“▲” Else zw=“▲”+zw+“▲” End If List 1.Add Item
1.大部分社交軟件都有好友推薦的功能,當用戶 A 和用戶 B 的共同好友數量超過閾值 p 時,由系統向用戶 A 推薦用戶 B。 編寫 VB 程序,實現好友推薦功能。運行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標用戶 id,在文本框 Text2 中輸入閾值 p,點擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關系,在標簽 Label5 中顯示向目標用戶推薦的好友列表。程序運行界面如圖: (1)根據如圖所示數據,若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: