- 基础理论
- 数据及数据库技术
- 人工智能
- 算法理论
- 算法实例
- 面向对象程序设计 VB开发工具
- 算法实例的程序实现
- 算法及算法的表示方法
- 多媒体理论
- 基础软件操作
- 算法软件操作
- 多媒体软件操作
- 网络技术应用
有一个由4000个整数构成的顺序表,假定表中的元素已经按升序排列,采用二分查找定位一个元素。则最多需要( )次比较就能确定是否存在所查找的元素。
A.11次 | B.12次 | C.13次 | D.14次 |
下表记录了6个数据的排序过程。分析表中数据可知,该排序采用的算法与排序方式分别为( )
原始数据 | 65 | 57 | 59 | 44 | 45 | 69 |
第1遍 | 44 | 65 | 57 | 59 | 45 | 69 |
第2遍 | 44 | 45 | 55 | 57 | 59 | 69 |
第3遍 | 44 | 45 | 57 | 65 | 59 | 69 |
… | … | … | … | … | … | … |
A.冒泡排序,升序 | B.选择排序,升序 |
C.冒泡排序,降序 | D.选择排序,降序 |
输入一正整数并判断是奇数还是偶数的算法描述如下图所示:

该流程图中,语句“x mod 2 = 0?”,应加的框图为( )

该流程图中,语句“x mod 2 = 0?”,应加的框图为( )
A.![]() |
B.![]() |
C.![]() |
D.![]() |
设计VB程序,该程序将输入的字符串中小写字母转换成大写字母后输出。在文本框Text1中输入一串字符(数字、字母均可),单击“转换”按钮Command1,在标签Label2中输出结果。(提示:Asc(x):将字符x转换为ASCII码值;Chr(x):将ASCII代码x转换为所对应的字符)该程序的设计界面如图所示,请根据算法将下列程序补充完整。

Private Sub Command1_Click()
Dim ch As String, s As String
Dim i As Integer, j As Integer
ch = Text1.Text
For i =" 1" To (1)
j =" Asc(Mid(ch," i, 1))
If j > 96 And j < 123 Then
s =" s" + Chr(j - 32)
Else
s =" s" + Chr(j)
End If
Next
(2)
End Sub

Private Sub Command1_Click()
Dim ch As String, s As String
Dim i As Integer, j As Integer
ch = Text1.Text
For i =" 1" To (1)
j =" Asc(Mid(ch," i, 1))
If j > 96 And j < 123 Then
s =" s" + Chr(j - 32)
Else
s =" s" + Chr(j)
End If
Next
(2)
End Sub
杭州市民卡是由杭州市人民政府授权发放给市民用于办理个人相关事务和享受公共服务的集成电路卡(IC卡),具有信息储存、身份识别、电子支付等功能。每位市民卡的卡号是唯一的,卡内会记录每位市民的姓名、住址、金额等信息。
假设共有1000个市民,市民的相关信息都存储在“information.accdb”的data表中,查询程序界面如图所示。工作人员在文本框Text1中输入卡号,单击“开始查询”按钮,如果找到,就在Label1中显示卡内市民姓名和卡内余额;否则显示“查无此人”。请按要求将下列程序补充完整。

Private Sub command1_click()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim strSQL As String
Dim a,b as string ‘分别定义姓名、余额
Dim n as integer
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.12.0;Data" Source=" + App.Path + "\information.accdb" '打开到数据库的链接
conn.Open
strSQL ="select xh,xm from data where '卡号=&(Text1.Text) & '" '设置查询的SQL语句
Set rs.ActiveConnection = conn '设置rs的ActiveConnection属性,指定与其关联的数据库链接
rs.Open strSQL '打开记录集,将从表information中读取的结果保存到记录集rs中
Label1.Caption = ""
n=0
Do while not rs.EOF
①
a=rs.Fields("姓名")
b=rs.Fields("余额")
rs.movenext
loop
rs.Close
conn.close
set rs=nothing
set conn=nothing
②
if n="0" then Label1.caption="查无此人"
End Sub
(1)程序中①划线处应填入___________________。
(2)程序中②划线处应填入___________________。
假设共有1000个市民,市民的相关信息都存储在“information.accdb”的data表中,查询程序界面如图所示。工作人员在文本框Text1中输入卡号,单击“开始查询”按钮,如果找到,就在Label1中显示卡内市民姓名和卡内余额;否则显示“查无此人”。请按要求将下列程序补充完整。

Private Sub command1_click()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim strSQL As String
Dim a,b as string ‘分别定义姓名、余额
Dim n as integer
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.12.0;Data" Source=" + App.Path + "\information.accdb" '打开到数据库的链接
conn.Open
strSQL ="select xh,xm from data where '卡号=&(Text1.Text) & '" '设置查询的SQL语句
Set rs.ActiveConnection = conn '设置rs的ActiveConnection属性,指定与其关联的数据库链接
rs.Open strSQL '打开记录集,将从表information中读取的结果保存到记录集rs中
Label1.Caption = ""
n=0
Do while not rs.EOF
①
a=rs.Fields("姓名")
b=rs.Fields("余额")
rs.movenext
loop
rs.Close
conn.close
set rs=nothing
set conn=nothing
②
if n="0" then Label1.caption="查无此人"
End Sub
(1)程序中①划线处应填入___________________。
(2)程序中②划线处应填入___________________。
下列VB程序运行时,单击命令按钮Command1后,在文本框Text1中输入“1024”,语句“a(i)=a(i+1)/2”共被执行了________次。
Private Sub Command1_C1ick ( )
Dim a(9) As Integer
a(9)=Val(Text1.text)
For i="8" to 1 step -2
a(i)=a(i+1)/2
Next i
Text2.text=str(a(i))
End Sub
Private Sub Command1_C1ick ( )
Dim a(9) As Integer
a(9)=Val(Text1.text)
For i="8" to 1 step -2
a(i)=a(i+1)/2
Next i
Text2.text=str(a(i))
End Sub
有Visual Basic程序如下:
Private Sub Command1_Click()
Dim a As String
Dim b As String
Dim c As String
a = Text1.Text
b = Text2.Text
c =" a" + b
Label1.capton = c
End Sub
程序运行时,单击命令按钮command1,弹出如图所示的出错信息提示,此时程序正执行的语句是( )

Private Sub Command1_Click()
Dim a As String
Dim b As String
Dim c As String
a = Text1.Text
b = Text2.Text
c =" a" + b
Label1.capton = c
End Sub
程序运行时,单击命令按钮command1,弹出如图所示的出错信息提示,此时程序正执行的语句是( )

A.a = Text1.Text | B.b = Text2.Text |
C.c =" a" + b | D.Label1.capton = c |
采用冒泡排序将六个数“22,14,18,17,21,16”从小到大进行排序,则第二轮交换数据后的顺序是( )
A.14,22,16,18,17,21 | B.14,16,18,17,21,22 |
C.14,16,22,17,18,21 | D.14,22,16,17,18,21 |
有序数列3.6,8,11.6,22,24,27,31,36.5,35,46,通过对分查找查找数31,需找( )次
A.4 | B.3 | C.2 | D.1 |