题型:综合题 题类:常考题 难易度:困难
浙江省瑞安市上海新纪元高级中学2019-2020学年高二下学期信息技术期末考试试卷
Dim a(1 To 100) As Integer, n As Integer
Private Sub Form_Load()
'本过程从数据库中读取n个IP地址区间数据,并依次存入数组a(1)、…、a(2*n)中
'对能通过过滤的IP区间按区间起始端点升序排序
'代码略
End Sub
Private Sub Cmd1_Click()
Dim ip As Integer, L As Integer, R As Integer
Dim i As Integer, pos As Integer, f As Boolean
ip = Val(Text1.Text)
L = a(1): R = a(2): i = 3: pos = 1 ‘合并重叠区间
Do While i <= 2 * n - 1
If Then
If a(i + 1) > R Then R = a(i + 1)
Else
a(2 * pos - 1) = L:a(2 * pos) = R
pos = pos + 1
L = a(i)
R = a(i + 1)
End If
Loop
a(2 * pos - 1) = L: a(2 * pos) = R '依次输出排序合并后的区间数据,代码略
If Then '判断请求的 IP 地址
Label4.Caption = "IP 需过滤"
Else
i = 1: f = False
Do While i <= pos And Not f
If Then
i = i + 1
Else
Label4.Caption = "IP 不需过滤" f = True
End If
Loop
If f = False Then Label4.Caption = "IP 需过滤"
End If
End Sub
试题篮