(選填:能/不能)構成“幻圓”。 (2)請在橫線處填入合適的代碼。 Dim a(1 To 7)As Integer'a(1)~a(7)依次存儲區域①~⑦的值 Private Sub Command1_Click ( ) Dim i As Integer,n As Integer Dim y1 As Integer,y2 As Integer,y3 As Integer For i=1 To 7 a(i)=i Next i n=0 Do While True For i=7 To 2 Step-1 If a(i)=8 Then a(i)=1
a(i-1)=a(i-1)+1
a(i-1)=a(i-1)+1
End If Next i If a(1)=8 Then Exit Do If check
( )
( )
Then y1=a(1)+a(2)+a(3)+a(4) y2=a(2)+a(4)+a(5)+a(6) y3=a(3)+a(4)+a(6)+a(7) If y1=y2 And
y1=y3
y1=y3
Then n=n+1 '在列表List1中,按格式輸出a數組元素的值,代碼略 End If End If a(7)=a(7)+1 Loop Label1.Caption=“解法共計“& Str(n) &“種。“ End Sub Function check
( )
( )
As Boolean Dim i As Integer,n As Integer,f(1 To 8)As Integer For i=1 To 8 f(i)=0 Next i For i=1 To 7
f(a(i))=1
f(a(i))=1
Next i n=0 For i=1 To 7 n=n+f(i) Next i If n=7 Then check=True Else check=False End Function
1.大部分社交軟件都有好友推薦的功能,當用戶 A 和用戶 B 的共同好友數量超過閾值 p 時,由系統向用戶 A 推薦用戶 B。 編寫 VB 程序,實現好友推薦功能。運行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標用戶 id,在文本框 Text2 中輸入閾值 p,點擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關系,在標簽 Label5 中顯示向目標用戶推薦的好友列表。程序運行界面如圖: (1)根據如圖所示數據,若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: