例如:依次输入以下区间:[2 5],[4 7],[1 4],[5 9],[4 5],[2 4],数轴如下:
坐标点“4”覆盖了[2 5],[4 7],[1 4],[4 5],[2 4]共5个区间,坐标点“9”覆盖了[5 9]区间,所以覆盖这6个区间所需的坐标点数为2个。
程序运行界面如图所示。
实现上述功能的VB代码如下:
Dim n As Integer
Dim a(1 To 100) As Integer
Private Sub Input_Click()
'输入n个正整数区间,依次存放到数组
'a(1)到a(2*n)中,并在List1中显示
'代码略
End Sub
Private Sub Count_Click()
Dim right As Integer, t As Integer, k As Integer
Dim tmp As Integer, i As Integer, ans As Integer
‘改错
ans = 1: t = 3
Do While t < 2 * n
If ① Then
If a(t + 1) < right Then right = a(t + 1)
Else
ans = ans + 1
right = a(t + 1)
End If
②
Loop
Text3.Text = Str(ans)
End Sub
请回答下列问题:
① ②