- 基础理论
- 数据及数据库技术
- 人工智能
- 算法理论
- 过程和自定义函数
- 枚举算法及程序实现
- 解析算法及程序实现
- 递归算法及程序实现
- 排序算法及程序实现
- + 查找算法及程序实现
- 多媒体理论
- 基础软件操作
- 算法软件操作
- 多媒体软件操作
- 网络技术应用

数组元素a(1)到a(10)的值依次为“66,34,12,59,21,26,18,45,20,16”,经过该程序段“加工”后,数组元素a(1)到a(10)的值依次为( )
A.66,12,16,34,18,59,21,26,20,45 |
B.12,16,18,20,21,26,34,45,59,66 |
C.66,59,45,34,12,26,21,20,18,16 |
D.12,16,18,66,34,20,59,21,26,45 |
(1)11 99 5 17 2 39
(2)30 52 63 71 78 81
(3)67 62 68 6 15 15
(4)85 78 59 53 19 18
A.(3)(4) | B.(2)(3) | C.(1)(2) | D.(2)(4) |
c=0:i=1:j=8
key=Val(Text1.Text)
f= False
Do While i<=j And Not f
m=Fix((i+j)/2+0.5)
c=c+1
If key=d(m) Then
f= True
Else If key>d(m) Thenj=m-1
Elsei=m+1
End IfLoop
数组元素d(1)到d(8)的值依次为“97,79,68,48,35,23,18,10”,若运行该程序段后,c的值为2,则文本框Text1中输入的值是( )
A.68或18 | B.68或23 | C.79或23 | D.79或18 |
i=1:j=7:n=0
Key=Val (Text l. Text)
Do While i <=j
n=n+1
m=Int ((i+j)/2)
If Key=d(m) Then Exit Do
If Key <d(m) Then j= m-1 Else i =m+ l
Loop数组元素d(1)到d(7)存放的数值依次为6,45,23,36,78,58,12,若该程序段运行结束后,n的值为2,则Key的值是( )
A.58 | B.6或12 | C.45或58 | D.23或78 |
i=1:j=n 'n代表学生的数量
Key=Val(Text1.Text)
Do While i<=j
m=

If Val(a(m))>Key Then i=m\2+1 Else j=m\2-1
Loop
List1.Clear
j=j+1
Do While i<=n
If Val(a(2*j))=Key Then List1.AddItem a(2*j-1)+""十a(2*j)
Else exit do
j=j+1
Loop上述程序中方框处可能的语句是( )
A.(i+j)\2 | B.(i+h)/2 | C.((i+j)12)*2 | D.((i+j)\2)/2 |
查找最短26个字母字符串的算法可描述为:
1)确定初始右边界: 从第1个字符开始,向右搜索到包含全部26个字母的子串,并因此而确定右边界,同时记录每个字母在子串中出现过的次数。
2)调整子串左边界: 若左边界有重复的字母则表明该子串可缩短,故左边界可右移1位,……直到找到一个符合条件的子串并记录,然后子串左边界再右移1位。
3)调整子串右边界: 子串右边界继续右移,在新子串符合条件后,记录并进行比较。重复2)各调整步骤,直至遍历完整个字符串,获得并输出满足条件的最小长度字符串。

实现上述功能的VB程序如下,请回答下列问题:
(1)对于字符串“ qbwcadsgeqbdatcy”,包括字母 abcde的最短字符串长度为___________(填数字)
(2)请在划线处填入合适的代码。
Const n=200
Dim i As Integer, k As Integer, length As Integer, L As Integer
Dim pos As Integer, sl As String, res As String
Dim f(1 To 26) As Integer '数组f记录每个小写英文字母的出现次数
Dim s(1 To n)As Integer '数组s记录每个输入字符在字母表中的位置
Private Sub Command1_ Click
res=" "
s1=Textl. Text
For i=1 To Len(s1)
s(i)= _____________Next i
k=0: pos=1: length=n
For i=1 To 26
f(i)=0
Next i
For i=1 To Len(sl)
If f(s(i))=0 Then k=k+1
f(s(i))=f(s(i))+1
Do While___________
f(s(pos))=f(s(pos))-1
If______________Then
k=k-1
If i-pos+1<length Then
length=i-pos+1
res=Mid (sl, pos, length)
L=pos
End If
End If
pos=pos+1
Loop
Next i
If res<>""Then
Text2 Text=res
Labell. Caption="最短长度: "+Str( length)+"开始位置: "+Str(L)Else
Labell. Caption="无解!"
End if
End SubDim a(l to 6)As Integer
i=1: j=6: n=0
key= Val(Textl. Text)
Do While i<=j
n=n+1
m=(i+j)\2
If key=a(m) Then Exit Do 'Exit do为退出do循环
If key<a(m) Then
j=m-1
Else
i=m+1
LOOP
数组元素a(1)到a(6)的值依次为“1921,1927,1949,1998,2008,2019”。在文本框Text1中输入“1998”后运行该程序,则以上程序段运行结束后,下列说法正确的是( )
A.变量i的值为3 |
B.变量j的值为5 |
C.变量m的值为3 |
D.变量n的值为3 |

(1)要使程序启动后,窗体的标题栏显示“纪念品分组”文字,可在 Form Load事件过程中添加语句 (单选,填字母:
A.Form1="纪念品分组"/ | B.Form1.Name="纪念品分组"/ | C.Form1. Caption="纪念品分组"/ | D.Fom1.Text="纪念品分组")。 |
Private Sub Command1 Click()
Dim a(l To 1000), n As Integer, w As Integer,cnt As Integer
Dim i As Integer, j As Integer, t As Integer
Dim s As String, ch As String
Dim p As Integer, q As Integer
S= Textl. Text: w =Val(text2. Text): n=0
For i=1 To Len(s)
ch=Mid(s, i, 1)
If ch="."Then
n=n+1:a(n)=t: t=0Else
t=_________①___________
End If
Next iFor i=n To 2 Step-1
For j=1 To '②
t=a(j):a(j)=a(j+1):a(j+1)=t
End If
Next jNext i
cnt= 0
p=1: q=n
Do While p<q
cnt=cnt+1
If ________③_________ Then
p=p+1:q=q-1
Else
p=p+1End If
LoopIf p=q Then cnt=cnt+1
Label2 Caption- Str(cnt)
End sub
(3)若在文本框Text1中输入“50,30,100,70,80,40,50,20”,文本框Text2中输人“110”,单击“分组”按钮,标签Labe2中显示的内容是____________。
i=1:j=8:c=0
key= Val(Textl. Text)
Do While i<=j
m=Int((i+j)/2)
t=b(m)
c=c+1
If a(t)=key Then p=t:Exit Do
If a(t)<key Then
i=m+1Else
j=m-1End If
Loop当文本框 Text1中输入的值为32时,程序运行结束后变量c的值为( )
A.1 | B.2 | C.3 | D.4 |
k= Val(Text1.Text)
i=1:j=6:Label1.Caption="":f=False
Do While i<=j And Not f
m=(i+j)\2
If a(m)=k Then f= True
If a(m)>a(i) Then
If a(i)<=k And k<a(m)Then j=m-1 Else i=i+1
ElseIf a(m)<k And k<=a(j)Then i=i+1 Else j=j-1
End IfLabel1 Caption=Label1 Caption+ Str(a(m))
Loop
数组元素a(1)到a(6)的值依次为“58,66,72,24,35,40”,在文本框Text1中输人的值为35,执行该程序段,标签 Label1中显示的值是( )
A.72 35 | B.24 35 |
C.72 24 35 | D.72 24 24 35 |