- 基础理论
- 数据及数据库技术
- 人工智能
- 算法理论
- 算法实例
- 面向对象程序设计 VB开发工具
- 算法实例的程序实现
- 算法及算法的表示方法
- 多媒体理论
- 基础软件操作
- 算法软件操作
- 多媒体软件操作
- 网络技术应用
下列VB程序运行时,在文本框Text1中输入“h”后,单击命令按钮Command1后,标签框Label1中显示的内容是____ ____。
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
a = Chr(Asc(a) - 32)
Label1.Caption = a
End Sub
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
a = Chr(Asc(a) - 32)
Label1.Caption = a
End Sub
表达式 len(“Good Morning”)+2 mod 3 +int(3.9999)的值为( )
A.15 | B.16 | C.17 | D.表达式运算出错 |
实现计算器上xy运算处理的算法部分流程图如图所示:

下列说法正确的是( )

下列说法正确的是( )
A.框图①中该填入的是f←x*j |
B.框图①中该填入的是f←f*j |
C.j←j+1被执行了x次 |
D.j←j+1被执行了y次 |
某商场元月举行VIP客户积分换购活动,VIP客户根据卡内积分多少可换取不同额度的代金券。假设VIP客户共有n名,VIP卡内积分存放在数据库“customer.accdb”的Integral表中,换购活动的VB程序代码如下,程序运行时界面如图所示。工作人员在文本框Text1中输入VIP卡号后,单击“换购”按钮Command1,在文本框Text2中输出VIP客户的积分数,在标签Label3中显示可以换购的代金券额度,积分清零。按此要求编写程序如下, 但加框处代码有错,请改正。

Dim ID( ) As String '用于存放客户卡号
Dim total( ) As Long '用于存放积分数
Dim sc As Long 'VIP客户人数
Dim jf As Long '积分数
Private Sub Command1_Click( )
Dim k As String '客户卡号
Dim q As Long '代金券额度
Dim i As Long
k = Text1.Text
For i =" 1" To sc ’顺序查找
If ID(i) =" k" Then
jf = total(i)
cash(jf) = q ’①
Exit For
End If
Text2.Text = Str(jf)
Label3.Caption = “您可换购的代金券总额为:”+ Str(q) + “元”
Next i
End If
End Sub
' cash函数用于计算VIP客户可换购的代金券额度
Function cash(jf As Long) As Long
If jf >=" 2000" And jf <=" 20000" Then
Cash = jf\2000*10
ElseIf jf > 20000 And jf <=" 50000" Then
Cash = jf\2000*11
ElseIf jf > 50000 And jf <=" 100000" Then
Cash = jf\2000*12
ElseIf jf > 100000 And jf <=" 150000" Then
Cash = jf\2000*13
Else jf > 150000 Then ’ ②
Cash = jf\2000*14
End If
End Function
Private Sub Form_Load()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim intSQL As Long
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.12.0;Data" Source=" + App.Path + "\ customer.accdb"
conn.Open
intSQL = "SELECT score FROM Integral"
Set rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
rs.Open intSQL
sc = 0
Do While Not rs.EOF
sc =" sc" + 1
total(sc) = rs.Fields("score")
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End Sub
(1)加框处①有错,应改为_____________________。
(2)加框处②有错,应改为_____________________。

Dim ID( ) As String '用于存放客户卡号
Dim total( ) As Long '用于存放积分数
Dim sc As Long 'VIP客户人数
Dim jf As Long '积分数
Private Sub Command1_Click( )
Dim k As String '客户卡号
Dim q As Long '代金券额度
Dim i As Long
k = Text1.Text
For i =" 1" To sc ’顺序查找
If ID(i) =" k" Then
jf = total(i)
cash(jf) = q ’①
Exit For
End If
Text2.Text = Str(jf)
Label3.Caption = “您可换购的代金券总额为:”+ Str(q) + “元”
Next i
End If
End Sub
' cash函数用于计算VIP客户可换购的代金券额度
Function cash(jf As Long) As Long
If jf >=" 2000" And jf <=" 20000" Then
Cash = jf\2000*10
ElseIf jf > 20000 And jf <=" 50000" Then
Cash = jf\2000*11
ElseIf jf > 50000 And jf <=" 100000" Then
Cash = jf\2000*12
ElseIf jf > 100000 And jf <=" 150000" Then
Cash = jf\2000*13
Else jf > 150000 Then ’ ②
Cash = jf\2000*14
End If
End Function
Private Sub Form_Load()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim intSQL As Long
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.12.0;Data" Source=" + App.Path + "\ customer.accdb"
conn.Open
intSQL = "SELECT score FROM Integral"
Set rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
rs.Open intSQL
sc = 0
Do While Not rs.EOF
sc =" sc" + 1
total(sc) = rs.Fields("score")
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End Sub
(1)加框处①有错,应改为_____________________。
(2)加框处②有错,应改为_____________________。
有6位学生的身高分别为165,170,172,175,176,180。其中,小民的身高为175,若老师采用对分查找法想要找到小民,则需要找多少次才能够找到( )
A.2 | B.3 | C.4 | D.5 |
素数:只能被1和它本身整除的自然数。要求编写VB程序找出任意两个整数之间中所有的素数及个数,程序运行界面如下图所示。

请根据算法将下列程序补充完整。
Function prime(a As Integer) As Boolean
Dim j As Integer
prime = True
j = 2
Do While prime And j <=" a" \ 2
If a Mod j =" 0" Then
prime = False
Exit Do
End If
①
Loop
End Function
Private Sub Command1_Click( )
Dim i As Integer, a As Integer, b As Integer
Dim count As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
For i =" a" To b
If ② =" True" Then
List1.AddItem Str(i)
count =" count" + 1
End If
Next i
Label1.Caption = "素数共有" + Str(count) + "个!"
End Sub

请根据算法将下列程序补充完整。
Function prime(a As Integer) As Boolean
Dim j As Integer
prime = True
j = 2
Do While prime And j <=" a" \ 2
If a Mod j =" 0" Then
prime = False
Exit Do
End If
①
Loop
End Function
Private Sub Command1_Click( )
Dim i As Integer, a As Integer, b As Integer
Dim count As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
For i =" a" To b
If ② =" True" Then
List1.AddItem Str(i)
count =" count" + 1
End If
Next i
Label1.Caption = "素数共有" + Str(count) + "个!"
End Sub
下面是用于实现S=1*2+3*4+5*6+7*8+9*10的算法的流程图,则划线处分别应填写:( )


A.S<=10 I←I+1 |
B.I<=10 I←I+1 |
C.S<10 I←I+2 |
D.I<10 I←I+2 |
A班一组同学的英语成绩分别为24、27、16、15、24、18,下列采用排序算法及第二遍的排序结果分别为( )
原始数据 | 24 | 27 | 16 | 15 | 24 | 18 |
第一遍 | 27 | 24 | 16 | 15 | 24 | 18 |
第二遍 | | | | | | |
第三遍 | 27 | 24 | 24 | 15 | 16 | 18 |
第四遍 | 27 | 24 | 24 | 18 | 16 | 15 |
第五遍 | 27 | 24 | 24 | 18 | 16 | 15 |
A.冒泡排序,27 24 16 15 24 18 | B.冒泡排序,27 24 18 16 15 24 |
C.选择排序,27 24 16 15 24 18 | D.选择排序,27 24 18 16 15 24 |
以下语句运行后变量c的值是( )
a=”2009”
b=”2008”
c=Val(a)+Val(b)
a=”2009”
b=”2008”
c=Val(a)+Val(b)
A.2009+2008 | B.4017 | C.”20092008” | D.20092008 |