修改时间:2024-07-31 浏览次数:170 类型:月考试卷
i = 1: j = 8: s = ""
key =Text1.Text
Do While i <= j
m =(i + j) \ 2
If key = a(m) Then
s = s + "M"
Exit Do
ElseIf key > a(m) Then
j = m - 1: s = s + "L"
Else
i = m + 1: s = s + "R"
End If
Loop
Text1.Text = s
数组元素a(1)到a(8)的值依次为“4,22,27,32,35,44,56,59”,该程序段执行后,文本框Text1中显示的内容不可能是( )
For i = 1 To 2
For j = 1 To 6 - 2 * i
If a(j) < a(j + 2) Then
t = a(j): a(j) = a(j + 2): a(j + 2) = t
End If
Next j Next i
数组元素a(1)~a(6)的初始值依次为“15,13,44,38,26,7”,执行该程序段后,数组a元素的值分别为( )
Dima( 1 To 5) As Integer
Dimi As Integer, j As Integer, s As String
s=“”
For i= 2 To 5
For j=i To 5
If j Mod i=0 Then a(j) =a(j)+1
Next j
Next i
For i= 1 To 5
If a(i) <>1Then s=Str(i) +s
Next i
Text 1.Text=S
若数组a的初始值都为0,则运行该程序段后,Text 1中显示的内容为( )
For i= 1 To 10
b(i)=0
Next i
For i= 1 To 5
For j= 1 To 10
If b(i) <a(j) Then
b(i)=a(j)
t=j
End If
Next j
a(t)=0
List 1.Additem Str(b(i) )
Next i
其中数组元素a(1)到a(10)的值依次为“25,42,53,66,77,83,98,14,38,99”,执行程序后,在列表框List 1中依次输出的数据是( )
count=0
For i=1 To 20
a(i) =Int(Rnd*100) + 1
Next i
For i= 1 To 20
①
Next i
For i= 1 To 100
If b(i) <> 0 Then count =count+1
Next i
Label 1.caption=“不重复数字个数”+Str(count)
为实现上述功能,则程序①处应填入的语句为( )
Dim i As Integer, sum As Integer
Dim a(1 To 6) As Integer, b(1 To 6) As Integer
sum = 0
a(6) = 18: a(5) = 7: b(6) = 14: b(5) = 16
For i = 4 To 1 Step -1
a(i) = a(i + 2) - a(i + 1)
b(i) = b(i + 2) - a(i)
If b(i) Mod 3 = 0 Then sum = sum + b(i)
Next i
Text1.Text = Str(sum)
该程序段运行后,文本框Text1中显示的内容是( )
Dim a( 1 To 10) As Integer
Function Search(L As Integer, R As Integer)
As Integer
M=(L+R)\2
If a(M) <a(M-1) And a(M) >a(M+1) Then
①
ElseIf a(M) >a(M-1) And a(M) >a(M+1) Then
②
ElseIf a(M) >a(M-1) And a(M) <a(M+1) Then
③
End If
End Function
Private Sub Command 1 click()
Label 1.caption=““峰顶”值是:” +Str(Search (1,10))
End Sub
上述程序中划线处可选语句为:
①Search=Search(M+1,R)
②Search=Search(L,M-1)
③Search=a(M)
则①②③处的语句依次是( )
For i=1To n\2
k=i
If a(j) <a(k) Then k=j
Next j
If i<>k Then
t=a(i):a(i)=a(k):a(k)=t
End If
If Then
t=a(j):a(j)=a(j+1):a(j+1)=t
End If
Next j
Next i
上述程序中方框处可选语句或表达式有:
①For j=i+1 To n-i+ 1 ②For j=i+1 To n-i
③a(j)<a(j+1) ④a(j)>a(j+1)
则(1)、(2)、(3)处语句依次是( )
key=Va 1(Text 1.Text)
i=1
j=9
Text 2.Text=""
Do While i<=j
If key=a(m) Then Exit Do
If key<a(m) Then i=m+1 Else j=m-1
Text 2.Text=Text 2.Text+“”+Str(a(m) )
Loop
数组元素a(1)到a(9)的值依次为88,75,70,68,61,58,55,50,43,文本框Text 1中输入的值是58,执行该程序段,文本框Text 2中显示的是61,50,55,则方框处的代码应为( )
y=0
n=Len(Text 1.Text)
For i=1To n
c=Mid(Text 1.Text,i,1)
If c>=“0”And c<=“9”Then
x=Val(c) :a(x) =a(x) + 1
End If
Next i
For i= 0 To 9
If a(i) >0Then y=y+ 1
Next i
Label 1.Caption=Str(y)
a数组各元素的初值为0,程序运行时,在文本框Text 1中输入内容“pi=3.1415926535”,单击按钮Command 1后,标签Label 1中显示的内容是( )
试题篮