当前位置: 首页 » 中职教育 » 冲刺2021届浙江省高考选考信息技术二轮专题04 选择排序算法及VB程序实现(原卷)

冲刺2021届浙江省高考选考信息技术二轮专题04 选择排序算法及VB程序实现(原卷)

专题4 选择排序算法及VB程序实现
(专项练习)
1. 某校通过政府招投标中心采购一套多媒体教学设备,有5家单位参加竞标,竞标价分别为19万、15
万、21万、13万、12万元人民币。 若采用选择排序算法对标价从大到小排序,需要进行数据互换的
次数是( )
A. 1 B. 2 C. 3 D. 4
2. 有如下 VB 程序段:
s = “26170534”: n = Len(s): y = “”
For i = 1 To n
ch(i) = Mid(s, i, 1)
Next i
For i = 1 To n
k = i
For j = i To n Step 2
If ch(j) < ch(k) Then k = j Next j If k <> i Then t=ch(k): ch(k)=ch(i): ch(i)=t
y = y & ch(i)
Next i
Label1.Caption = y
该程序段运行后,标签Label1中显示的内容是( )
A. 0123 B. 4567 C. 01234567 D. 04152637
3. 有如下VB 程序段:
For i = 5 To 4 Step -1
k = i
For j = 6 – i To 1 Step -1
If a(j) < a(k) Then k = j 第 1 页 共 6 页 Next j If i <> k Then
t = a(i): a(i) = a(k): a(k) = t
End If
Next i
数组元素a(1)到a(5)的值依次为“41,66,70,83,31”,经过该程序段“加工”后,数组元素a(1)到a(5)
的值依次为( )
A. 31,41,66,83,70 B. 83,70,66,41,31
C. 83,66,70,41,31 D. 31,41,66,70,83
4. 某VB 程序段如下:
i = 1
Do While i <= 3 min= i j = i + 1 Do While j <= 6 If a(j) < a(min) Then min= j j = j + 1 Loop If i <> min Then t=a(i): a(i)=a(min): a(min)=t
i = i + 1
Loop
数组元素a(1)到a(6)的值依次为“7, 8, 3, 9, 6, 2”,则上面程序段在运行后,数组元素a(1)到a(6)的数据依
次是( )
A.9, 8, 7, 3, 6, 2 B.2, 3, 6, 7, 8, 9
C.2, 3, 6, 9, 8, 7 D.9, 8, 7, 6, 3, 2
5. 有如下 VB 程序段:
s = “7218634594” : n = Len(s):c = 0
For i = 1 To n – 1
a(i) = Val(Mid(s, i, 2))

第 2 页 共 6 页

Next i
For i = 1 To n – 2 Step 2
k = i
For j = i + 2 To n – 1 Step 2
If a(j) < a(k) Then k = j Next j If k <> i Then
t=a(i): a(i)=a(k): a(k)=t: c=c+1
End If
Next i
Text1.Text = Str(c)
该程序段运行后,Text1 中显示的内容是( )
A. 1 B. 2 C. 3 D. 4
6. 某排序算法的VB 程序段如下:
For i = 1 To 4
k = i
For j = 5 To i + 1 Step -1
If a(j) < a(k) Then k = j Next j If k < > i Then
tmp = a(k): a(k) = a(i): a(i) = tmp
f(i) = True
End If
Next i
当数组元素a(1)到a(5)的值依次为“8,2,1,21,3”,数组f的初值均为False,执行该程序段,f 数组
中元素值为True 的个数有( )
A. 1 个 B. 2 个 C. 3 个 D. 4 个
7. 有如下VB程序段:
a(1) = 44: a(2)= 36: a(3)= 58: a(4)= 65: a(5)= 12

第 3 页 共 6 页

b = 0:c = 0
For i = 1 To 4
k = i
For j = i + 1 To 5
If a(j) < a(k) Then k = j: b = b + 1 Next j If k < > i Then
t = a(i): a(i) = a(k): a(k) = t
c = c + 1
End If
Next i
Text1.Text = Str(b) + Str(c)
该程序段执行后,文本框Text1显示的内容是( )
A. 53 B. 44 C. 43 D. 34
8. 某VB 程序段如下:
i = 1: s = “”
Do While i <= 3 k = i j = i + 1 Do While j <= 8 If a(j) < a(k) Then k = j j = j + 1 Loop If i < > k Then
t = a(i): a(i) = a(k): a(k) = t
n = n + 1
End If
s = s + Str(a(i)) : i = i + 1
Loop

第 4 页 共 6 页

Label1.Caption = Str(n) + “:” + s
数组a(1)到a(8)依次为:“16, 19, 8, 20, 4, 12,6, 15”,程序运行后,标签中显示的值为( )
A. 2:4 6 8 B.2:8 6 4 C. 3:4 6 8 D.3:8 6 4
9. 某学校举行校园歌手比赛,数组a存放歌手的得分,数组mc存放名次。名次计算规则为:先对数
组a中的元素按高到低的排序,分值最高为第1名,分值相同则名次相同。VB程序段的部分代码如下:
For i = 1 To 19
For j = 20 To i + 1 Step -1
If ① Then t =a(j): a(j)=a(i): a(i)=t /root/apache-tomcat-baidu_catch/baiduwenkutmp/4/476773194b649b6648d7c1c708a1284ac95005fd.pc/bdbc18c223d442199de783dd7142cc71.jpg.sub1.png
Next j
Next i
mc(1) = ② /root/apache-tomcat-baidu_catch/baiduwenkutmp/4/476773194b649b6648d7c1c708a1284ac95005fd.pc/bdbc18c223d442199de783dd7142cc71.jpg.sub2.png
For i = 2 To 20
If a(i) < > a(i – 1) Then ③ Else ④ /root/apache-tomcat-baidu_catch/baiduwenkutmp/4/476773194b649b6648d7c1c708a1284ac95005fd.pc/bdbc18c223d442199de783dd7142cc71.jpg.sub3.png/root/apache-tomcat-baidu_catch/baiduwenkutmp/4/476773194b649b6648d7c1c708a1284ac95005fd.pc/bdbc18c223d442199de783dd7142cc71.jpg.sub4.png
Next i
下列①②③④代码正确的是( )
A. ①处代码为 a(j) < a(i) B. ②处代码为 i C. ③处代码为 mc(i) = mc(i + 1) D. ④处代码为 mc(i) = mc(i - 1) 10. 将数组a 中的 8 个数据“ 18, 33, 5, 26, 86, 0, 60, 200”按从大到小的顺序,使用选择排序,则需要交 换的次数是( ) A. 4 B. 5 C. 6 D. 7 第 5 页 共 6 页 /root/apache-tomcat-baidu_catch/baiduwenkutmp/4/476773194b649b6648d7c1c708a1284ac95005fd.pc/e45c0279f8654cfb83d7a0f519e42fc7.jpg.sub1.png 专题4 选择排序算法及VB程序实现(专项练习)(参考答案)/root/apache-tomcat-baidu_catch/baiduwenkutmp/4/476773194b649b6648d7c1c708a1284ac95005fd.pc/e45c0279f8654cfb83d7a0f519e42fc7.jpg.sub2.png 1 2 3 4 5 6 7 8 9 10 B D C C B C C A D B