题型:综合题 题类:常考题 难易度:普通
浙江省稽阳联谊学校2020届高三下学期信息技术4月联考试卷
小蓝同学根据上述算法编写了一个VB程序实现比赛结果统计。每场比分记录在文本框text1中,单击“统计”按钮command1,把两队各场的比分按A队小分降序显示在列表框list1输出,同时在文本框text2输出最终结果。部分程序界面如图所示,VB代码如下,回答下列问题:
Private Sub Command1_Click()
Dim a(1 To 20) As Integer, b(1 To 20) As Integer
Dim i As Integer, j As Integer, t As Integer, p As Integer, k As Integer, xiaofen As Integer
‘从文本框读取比分,场次k,AB两队各场的得分分别记录在数组a、b,代码略
For i = 1 To k – 1 ‘对比分数据按A队小分降序排序
For j = 1 To ①
If ② Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
t = b(j): b(j) = b(j + 1): b(j + 1) = t
End If
Next j
Next i
p = 0: xiaofen = 0
For i = 1 To k ‘统计小分并输出比分
If a(i) > b(i) Then ③
xiaofen = xiaofen + a(i) - b(i)
List1.AddItem Str(a(i)) + ":" + Str(b(i))
Next i
If p * 2 > k Or k = p * 2 And xiaofen > 0 Then
Text2.Text = "A队获胜"
ElseIf Then
Text2.Text = "B队获胜"
Else
Text2.Text = "两队战平了"
End If
End Sub
① ② ③
试题篮