①在线中英文互译 ②制订旅游攻略时,安装 App 搜索景点信息 ③支持人脸识别的家用智能锁 ④用智能手机通过微信平台发送语音信息 ⑤使用 OCR 软件进行“倾斜校正”
n = 10: m = 0
For i = 1 To Int(Sqr(n))
If Not d(i) Then
j = 3 * i
Do While j <= n
d(j) = True
j = j + i
Loop
End If
Next i
For i = 5 To n
If d(i) Then m = m + 1
Next i
数组元素d(1)到d(10)的初值均为False,执行该程序段后,变量m的值为( )
i = 6: flag = True
Do While i >= 4 And flag = True
flag = False
k = i
For j = 1 To i - 1
If a(k) > a(j) Then k = j
Next j
If k <> i Then
t = a(i): a(i) = a(k): a(k) = t
flag = True
End If
i = i - 1
Loop
数组元素a(1)到a(6)的值依次为:“19,6,34,40,13,53”,执行该程序段后,数组元素a(1)到a(6)的值依次为( )
n = 8: f = 1: c = 0
For i = 1 To n \ 2 - 1
For j = 1 To n - 2 * i
If f * a(j) < f * a(j + 2) Then
t = a(j): a(j) = a(j + 2): a(j + 2) = t
c = c + 1
End If
f = -f
Next j
Next i
数组元素a(1)到a(8)的初始值依次为:“16,31,42,38,35,29,27,15”,执行该程序段后,变量C的值为( )
i = 1: j = 8: k = 4
Randomize
Key = (Int(Rnd * 4)+20)*4
Do While i <= j
m = (i + j) \ 2
If Key = a(m) Then
Exit Do
ElseIf Key < a(m) Then
j = m - 1: k = k / 2
Else
i = m + 1: k = k * 2
End If
Loop
数组元素a(1)到a(8)的值依次为“80,82,84,86,88,90,92,94”,执行该程序段后,变量k的值可能是( )
图 a |
图 a |
图 b |
实现上述功能的VB程序代码如下,请回答以下问题:
Const n = 50
Dim a(1 To n) As Integer
Dim f(n + 1 To 2 * n) As Boolean
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Randomize
For i = n + 1 To 2 * n
f(i) = False
Next i
For j = 1 To n
a(j) = Int(Rnd * n) + n + 1
If f(a(j)) = True Then j = j - 1 Else ①
Next j
For i = 1 To n
List1.AddItem CStr(i) + "号-" + CStr(a(i)) 'cstr 把数值类型转换为字符串类型,并去前导空格
Next i
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer, m1 As Integer, m2 As Integer
m1 = 0: m2 = n \ 2
For i = n + 1 To 2 * n
If ② Then
m1 = m1 + 1: a(m1) = i
Else
m2 = m2 + 1: a(m2) = i
End If
Next i
For j = 1 To n \ 2
List2.AddItem "第" + CStr(2 * j - 1) + "名" + Str( ③ ) List2.AddItem "第" + CStr(2 * j) + "名" + Str(a(n \ 2 + j))
Next j
End Sub
① ② ③
图 a |
图 b |
实现上述功能的 VB 程序如下,请回答下列问题:
Private Sub Command1_Click()
Const n = 6
Dim a(1 To n * n) As Integer
Dim b(1 To n * n) As String
Dim i As Integer, j As Integer, k As Integer, s As String
Dim zf As Integer '变量zf存储数组a元素的值
Dim xb As Integer '变量xb存储数组a的下标
Dim p As Integer
For i = 1 To Len(Text1.Text)
b(i) = Mid(Text1.Text, i, 1)
Next i
k = 1
For i = 1 To n
k = k + (i - 1)
zf = k
a(xb) = zf
p = i + 1
For j = 2 To n
If j <= n - i + 1 Then
zf = zf + p
a(xb + j - 1) = zf
p = p + 1
Else
zf = zf + p
a(xb + j - 1) = zf
End If
Next j
Next i
For i = 1 To n
s = s +
Next i
Text2.Text = s
End Sub