屬性(單選,填字母:A.Text/B.Form/C.Caption). (2)實(shí)現(xiàn)上述功能的VB程序如下,請?jiān)跈M線處填入合適的代碼。 ①
n>1
n>1
②
call px(n)
call px(n)
③
d(i)>d(i-1)
d(i)>d(i-1)
(3)程序中加框處代碼有錯,請改正。
ans=ans+d(n)
ans=ans+d(n)
Dim(1 To 100)As Integer Dim n As Integer Private Sub Form_Load ____ ’讀入n的值和n個包裹的重量依次存入d(1).d(n) End Sub Private Sub Command1 _Click ____ For i=1 To n Call px(i) Next i ans=0 Do While①
n>1
n>1
d(n-1)=d(n)+d(n-1) n=n-1 ans-ans+d(n)+d (n-1 ) ②
call px(n)
call px(n)
Loop Text1.text=ans End Sub Sub px(ByVal n As Integer) For i=n To 2 Step-1 If ③
d(i)>d(i-1)
d(i)>d(i-1)
Then tmp=d(i):d(i)=d(i-1):d(i-1)=tmp End If Next i End Sub
1.大部分社交軟件都有好友推薦的功能,當(dāng)用戶 A 和用戶 B 的共同好友數(shù)量超過閾值 p 時,由系統(tǒng)向用戶 A 推薦用戶 B。 編寫 VB 程序,實(shí)現(xiàn)好友推薦功能。運(yùn)行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標(biāo)用戶 id,在文本框 Text2 中輸入閾值 p,點(diǎn)擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關(guān)系,在標(biāo)簽 Label5 中顯示向目標(biāo)用戶推薦的好友列表。程序運(yùn)行界面如圖: (1)根據(jù)如圖所示數(shù)據(jù),若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: