二、填空题
1.下面程序是用“冒泡”法将数组a中的10个整数按升序排序,并将
排好序的结果显示在文本框中。请完善程序。(第19次考试填空)
Option Explicit
Option Base 1
Private Sub Form_Click()
___________
Dim i%, j%, t%
Text1.Text = \"\"
a = Array(345, 3, 65, 24, 765, 32, 56, 421, 54, 235)
For i = 1 To 9
For j = 1 To _____
If _________Then
t = a(j)
___________
a(j + 1) = t
End If
Next j
Next i
For i = 1 To 10
Text1.Text = Text1.Text & \" \" & a(i)
Next i
End Sub
2. 下面程序的功能是将一个整数转化为数值字符串,例如123,转换为“+123”(第19次程序阅读)
Private Sub ntoc(ByVal n!, strc As String)
Dim sign As Boolean, i%, a%, count%, temp%(100)
sign = False
If n < 0 Then sign = True: n = ________
Do While n > 0
a =__________
n = n \\ 10
count = count + 1
temp(count) = a
Loop
If sign Then strc = \"-\" Else strc = \"+\"
For i = count To 1 Step -1
strc = __________
Next i
End Sub
4.以下程序实现歌手评分功能。评分规则:在歌星大奖赛中,有10个评委为参赛的选手打分,分数为0~100分。选手最后得分为:去掉一个最高分和一个最低分后其余8个分数的平均值。(第21次程序填空)
Private Sub Commandl_Click()
Dim score(10) AS Integer
Dim max As Integer, min AS Integer,sam As Integer
Max=-1:min=101
For i=1 To 10
score(i)=Val(1nputBox(“score”))
sum=sum+score(i) ·
If _________①__________ Then max=score(i)
1f score(i) Print “去掉一个最高分:”,max Print ”去掉一个最低分:”,min Print ”歌手最后得分:”,___________③________ End Sub 5.QQ是一种常用的网络聊天工具,我们可以通过输入QQ号来查看对方是否在线。以下程序模拟了该查找功能。其中,在数组中按从小到的大方式存放了当前 在线的用户QQ号码,要求输入目标QQ号并判断该用户是否在线,请将程序补充完整。(第21次程序填空) Option Base 1 Private Sub Commandl_Click() Dim QQ QQ=Array(1234,2345,13098,77519,1522247,45687,8223879) Dim low As Long,high As Integer ,mid As Integer Dim objQQ AS Integer,isFound AS Boolean Low=1:high=7:isFound=False ObjQQ=Va(1nputBox(”目标QQ号:”)) Do While isFound=False And___________①_________________ mid=Int((low+high)/2) If objQQ=QQ(mid) Then _____________②______________ Elseif obiQQ Elseif obiQQ>QQ(mid)Then ______________③___________ End lf Loop If isFound=True Then Print objQQ,”在线” E1se Print objQQ,”不在线” End if End Sub 因篇幅问题不能全部显示,请点此查看更多更全内容