题型:综合题 题类:模拟题 难易度:困难
浙江省湖州市2021-2022学年高三上学期信息技术12月选考模拟(一)试卷
Const nc=10 '城市数
Const n=200000'志愿者总人数
Dim a(1 To n) As String'存储志愿者数据
Private Sub Form_Load()
'本过程读取志愿者数据,存入数组a并显示在列表框List1中,代码略
End Sub
Private Sub Command1_Click()
Dim city(1 To n) As Integer,pname(1 To n) As String,cs(1 To n) As Integer
Dim t As Integer,t1 As String
Dim b(1 To nc) As Integer '存储每个城市的报名人数
Dim index(1 To n) As Integer '定义索引数组
For i = 1 To n
city(i) = Val(Mid(a(i), 1, 1))
pname(i) =
cs(i) = Val(Mid(a(i), 7))
Next i
i = 1 '按城市序号升序排序
Do While i < n
k = i: i = n
For j = n To k + 1 Step -1
If city(j) < city(j -1) Then
t = city(j): city(j) = city(j -1): city(j -1) = t
t1= pname(j): pname(j) = pname(j -1): pname(j -1) = t1
t = cs(j): cs(j) = cs(j -1): cs(j -1) = t
End If
Next j
Loop
For i = 1 To n
index(i) = i
Next i
pos = 1 '相同城市志愿者按服务次数降序排序
For i = 1 To nc
For j = pos To pos + b(i) -2
k = j
For p = j + 1 To
If cs(index(p)) > cs(index(k)) Then k = p
Next p
t = index(j): index(j) = index(k): index(k) = t
Next j
pos = pos + b(i)
Next i
'最终结果显示在列表框List2中,代码略
End Sub
试题篮