(單選,填字母:A.對象名/B.屬性名/C.方法/D.屬性值)。 (2)請在橫線處填入合適的代碼。 (3)程序中加框處代碼有錯,請改正。 Dim n As Integer Dim a(1 To 100*100)As String Private Sub Command1_Click ( ) Dim i As Integer n=Val(Text1.Text) If n<=100 And n>=2 And n Mod 2=0 Then For i=1 To n*n a(i)=Chr (
Int(Rnd*2)+48
Int(Rnd*2)+48
)'字符“0“的ASCII碼值為48 '將初始矩陣顯示列表框List1中,代碼略 Next i Else List1.AddItem“輸入有誤“ End If End Sub Private Sub Command2_Click ( ) Dim b(1 To 100*100)As String,s As String Dim m As Integer,y As Integer,i As Integer,R As Integer,C As Integer m=Val(Text2.Text) If m>=2 And m<=n And m Mod 2=0 Then y=
(n-m)/2
(n-m)/2
s=““ For i=1 To n*n R=(i-1)\n+1:C=(i-1)Mod n+1 If R<=y Or R>n-y Or C<=y Or C>n-y Then b(i)=a(i) Else b(i)=a(n*C-R+1)'(3) End If s=s+b(i) If i Mod n=0 Then List2.AddItem s s=““ End If Next i Else List2.AddItem“輸入有誤“ End If 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”,則推薦好友為: