(單選,填字母:A.List1.Caption=““/B.List1.Text=““/C.List1.Clear)。 (2)實現上述功能的VB程序如下,請在橫線處填入合適的代碼。 (3)程序中(*)處代碼有錯,請改正。 Const m=20‘m表示申請人個數 Dim id(m)As Integer,qa(m)As Integer,qb(m)As Integer PrivateSubCommand1_Click ( ) Dim i As Integer,j As Integer,k As Integer,t As Integer,max As Integer Dim h As Integer,n As Integer’變量n存儲滿足條件一的申請人個數 Dim s As String ’讀取全部申請人的編號、QA和QB值,分別存入數組id、qa和qb,代碼略 h=Val(Text1.Text):n=m For i=1Tom-1 k=i For j=i+1Tom If qa(j)>qa(k)Then k=j Next j Ifqa qa(i)>h Then(*) f k<>i Then t=qa(i):qa(i)=qa(k):qa(k)=t t=qb(i):qb(i)=qb(k):qb(k)=t t=id(i):id(i)=id(k):id(k)=t End If Else n=①
Exit For’ExitFor表示退出循環 End If Next i ’滿足條件一的申請人信息顯示在列表框Listl中,代碼略 max=0:s=“沒有滿足條件的組合” ’在滿足條件的組合中,尋找QB值之和最大的組合,若有并列,只保留第一個 For i=n To 2 Step-1 j=i-1 Do While ②
If qb(i)+qb(j)>max Then s=“組隊結果:“+Str(id(i))+“號,“+Str(id(j))+“號“ ③
處(從ABCD處選擇一項填寫) Private Sub Command1_Click ( ) Dim a(0 To 10000)As Integer Dim n As Integer,start1 As Integer,end1 As Integer Dim i As Integer,j As Integer,k As Integer,sum As Integer Dim s As String,t As String,c As String n=Val(Text1.Text):s=Text2.Text For i=0 To n a(i)=1 Next i k=0:t=““ For i=1 To Len(s) c=Mid(s,i,1) If c<>“,“Then ①
Else k=k+1 If②
Then start1=Val(t) 'A Else end1=Val(t) For j=start1 To end1 ③
Next j 'B End If 'C End If 'D Next i sum=0 For i=0 To n If a(i)=1 Then sum=sum+1 Next i Label3.Caption=Str(sum) End Sub