资源描述
中国药科大学程序设计模拟试卷2009-2010学年第一学期专业 班级 学号一、基本概念(每小题1分,共25分)|请在答题卡上完成1. 已知a被定义为整型变量,执行语句a= 6 : a=a+6.5后,此时a的值为A . 0B . 1C. 2D . 3 2 .以下使用方确的语句是 。A . Combo1.Cls B . Form1.Cls C. Picture1.Clear D . Text1. Clear3. A为整形变量,调用已定义的 Sub过程:Private Sub change(B As Integer),以下 不是按值传递的语句是 。A . Call Change (A) B . change (A) C. Call Change (A) D . Change 14. 若要定义一个变量,使它仅能够在当前过程中访问,可以将其定义为 静态变量局部变量窗体/模块级变量全局变量A. B.C.D.5. 在Select Case X结构中,如果5 X 10是其中的一个判断条件,则正确描述5 X 10的测试项应该写成 。A . Case 5 To 10B . Case Is = 5C. Case 5 = X And X = 10D . Case 5 = X = 106. 窗体上有一个文本框Text1,假设已存在三个整型变量 a、b和c,且变量a、b和c的值分别为1、2和3,以下 语句可以使文本框中显示的容为:3=1+2A . Text1.Text = c = a + bB. Text1.Text = c=a+bC. Text1.Caption= c & = & a & + & bD. Text1 = c & = & a & + & b7 .以下叙述中错误的是 。A. VB中控件的某些属性只能在运行时通过代码来设置B. VB工具箱中的所有控件都具有宽度( Width)和高度(Height)属性C. VB的一个应用程序是由若干个不同类型的文件组成,即一个工程D. VB是事件驱动型的可视化编程工具8. 针对语句If X=True Then Y=False,下列说确的是。A . X= True是赋值语句,Y= False是关系表达式B . X= True和Y= False都是关系表达式C. X= True和Y= False都是赋值语句D . X= True是关系表达式,Y= False是赋值语句9. 下列有关变量的说法,正确的共有 个。 全局变量既可在窗体模块中定义,也可在标准模块中定义,访问时也一样 当访问的变量存在同名变量时,优先访问作用围小的变量 静态变量,从本质上来说是一个全局变量 所谓模块级变量,即专指在模块的通用声明中用Private定义的变量A . 1B . 2C. 310. 在Visual Basic中,以下叙述 是错误的。A. 控件数组中的控件可以是不同类型的控件B. 控件数组中的控件都有相同的名字C. 控件数组中的控件响应同一个事件D. 控件数组中的控件可以在运行时用代码生成11. 以下叙述中正确的是 。A. 可以在运行期间改变对象的Name属性的值B. 窗体的Name属性的值是显示在窗体标题栏中的文本C. 对象的Name属性值可以为空D. 窗体的Name属性指定窗体的名称,用来标识一个窗体12. 若在一个应用程序的窗体上,先后创建 Label、Frame、OptionButton等控件, 则运行程序显示该窗体时,会首先获得焦点是 。A .窗体B. LabelC. FrameD. OptionButton13. 定义三个变量i,j,k均为Integer类型,i = 3: j = 3.4: k = 2.5 ,执行语句 Print k = i = j 后,窗体上显示的是 。A . TrueB. FalseC. -1D . 014. 窗体上有一个名为Commandl的命令按钮,编写如下程序:Private Sub Commandl_Click()Static n As IntegerDim m As IntegerCls : m = 10 : m = m + 30 : n = m + n : Print m, nEnd Sub程序运行后,三次单击Commandl命令按钮,窗体上的显示结果为 A. 120 120 B. 40 4015. 在一个多窗体程序中,如果要将窗体 则下列语句正确的是 。A . Form1.Unload B . Form1.End16. 列表框中的列表项的数目可通过以下A . CountB. ListCountC. 40 120D. 120 40Form1从存中卸载,其他窗体仍然可用,C. Unload Form1 D . Form1.Hide属性的值获得。C. ListIndexD . Index17. 关于 Visual Basic的基本语句, 不是必须成对使用的。A . If 和 End If B. Do 和 Loop C. Select Case和 End Select D . For 和 Next18 .以下有关数组作为形参的说明中错误的是 。A. 形参数组只能按地址传递B. 实参为动态数组时,可在过程中用 ReDim语句改变形参数组的维界C. 调用过程时,只需把要传递的数组名填入实参表D. 形参若为数组就必须说明它的维界是多少19. 在默认状态下,若有数组声明:Dim a(5, 4 To 6) As Integer,下面数组元素引用中 正确的是。A. a(0,1)B. a(3,3) C. a(6,6)D. a(0,4)20. 表示“ A、B之一为零但不得同时为零”的VB逻辑表达式是 。A. A=0 Or B=0B. A=0 Xor B=0C. (A=0 Or B0) And (A0 Or B=0) D . (A=0 And B0) Or (A 2 Thenmoney = 0Elsemoney = (money(n + 1) + 10) / 2End IfPrint moneyEnd Function(29). A . 0B. 1C. 10D. 5(30). A . 3B . 15C. 5D. 10(31). A . 8.75B . 7.5C. 5D . 63、执行卜列程序,单击按钮后窗体上扣印的第一行为算一、第二行为(33)、第三行结果为(34)Private Sub Command1_Click()Dim a As Integer, i As Integer a = 7Fori = 1 To 3Print F(a)Next iEnd SubFunction F(a As Integer) Dim b As Integer Static c As Integer b = b + 1 : c = c + 2 F = a + b - cEnd Function(32)A .8B . 6C. 4D. 9(33)A .6B . 5C. 4D. -1(34)A .-1B . 4C. -2D. 24.执行卜面的程序,当单击命令按钮Command1时,囱体的第一仃显示的是(35)、第二行显示的是(36)、第三行显示的是(37)Private Sub Command1_Click()Dim s As String, i As Integer, s1 As Stringi = Asc(a) : s1 = ADoi = i + 1s = s1 + UCase(Chr(i) s1 = Right(s, 2) & Mid(s, 2, 1)Print s1Loop Until i = 100End Sub(35).A .BABB .ABB(36).A .BCBB .ABC(37).A .CCBB .DCB5、执行下列程序,单击按钮后窗体上打印的第 第三行为(40)。C.BAAD. ABAC.BABD. CBAC.BDCD. ABC行为(38)_、第二行为(39)、Private Sub Command1_Click()Dim a(1 To 9) As Integer, b(1 To 3, 1 To 3) As Integer, i As Integer, j As IntegerFori = 1 To 9a(i) = iNext iFori = 1 To 3Forj = 1 To 3b(i, j) = a(i * j)If j = i Then Print b(i, j);Next jPrintNext iEnd Sub(38)A .123B .23C .3D .321(39)A .456B .46C.56D .249(40)A .3B .6C.8D .9请在答题卡上完成、完善程序(每小题2分,共30分)3572i 1xxx/ ”i 1 xsum .(1)1!2!3!i!i 1,2,. 0 x 1Private Sub Command1_Click()Dim sum As Single, x As SingleDim sign As Integer, t As SingleDim i As Integer x = Val(Text1) sum = 0: i = 1 Dot =(46)sum = sum + t i = i + 1Loop (47)Text2 = Format(sum, #0.000) End Sub(46) A . (-1) A (i + 1) * x A (2 * i + 1) / fact(i)C. (-1) a (i + 1) * x a (2 i + 1) / fact(i)(47) A . Until t=10 a (-5)(48) A . If a = 1 then fact =1 B. fact = aPrivate Function fact(a As Integer) As LongDim i As Integer(48)For i = 1 To afact = fact * iNext iEnd FunctionB . x a (2 * i + 1) / fact(i)D . (-1) a i * x a (2 * i + 1) / fact(i)B. While Abs(t)1e-5D. While t1e-5C. fact = 1 D . fact = 01、找出10000以的所有完数并在列表框中输出,完数的个数在 Textl中输出。所谓 完数,是指它的所有的质因子之和等于它本身的数,如 6=1+2+3。Private Sub 运算 _Click()Private Function wshu(n As Integer) As (43)Dim i As IntegerDim i As Integer, s As IntegerFor i = 1 To 10000For i = 1 To n - 1If wshu(i) Then ( 41)If n Mod i = 0 Then(44)Next iNext iText1 = List1.(42)If s = n Then(45)End SubEnd Function(41) A . List1.Print i B . List1.text= i C. List1= iD . List1.AddItem i(42) A . ListB. ListCountC. ListIndexD. Text(43) A . LongB . IntegerC. StringD . Boolean(44) A . s = s + iB . s = s & iC. Exit ForD . Exit Function(45) A . wshu = nB . wshu = sC. wshu = True D . wshu = s + n2、本程序的功能是,利用下列公式求通项和S的近似值,规定通项的绝对值v10-5时结束累加。3、编程实现求32和12这两个数的最大公约数,单击单选按钮“过程 程2都可以在文本框 Textl中显示如图所示的结果。1 ”或“过Option ExplicitPrivate Sub Option1_Click(Index As Integer)Dim a As Integer, b As Integer, r As Integer a = 32: b = 12If Index = 0 Thenr = gcd1(a, b)ElseIf Index = 1 Then(49)End IfText1 = CStr(a) & 禾日& CStr(b) & End Sub Private Function gcd1(ByVal x As ByVal y As Integer) As Integer Dim r As Integer (50) Do While r 0 x = y: y = r r = x Mod yLoop(51End Function(49) A . r = gcd2(a, b)(50) A . r=0(51) A . gcd1 = x(52) A . gcd2 = x的最大公数为& CStr(r)Integer,Private Function gcd2(x As Integer, y As Integer) As IntegerDim r As IntegerDor = x Mod yx = y: y = rLoop While r 0(52)End FunctionC. r = gcd1(a), (b)D. r = gcd2(a), (b)C. r = xD . r = yC. gcd1(x,y) = xD. gcd1 (x,y) = yC. gcd2(x,y) = xD . gcd2 (x,y) = yB . r = gcd1(a, b) B . r = x Mod y B. gcd1 = y B. gcd2 = y10个数,统计其中不相同数据的个数。4、本程序的功能是产生Option ExplicitDim a(10) As IntegerPrivate Sub Command1_Click()Dim i As Integer RandomizeFori = 1 To 10a(i) = Int(90 * Rnd) + 10Text1 = Text1 &(53)Next iPrivate Sub Command2_Click() Dim i As Integer, j As Integer, f As Boolean, n As Integer Fori = 1 To 10 f = TrueFor j = i + 1 To 10If _(54)Then f = FalseEnd Sub(53) A. CStr(a(i)B. Str(a)C. CStr(a)D. Str(a(i)(54) A . a(i) = a(j)B a(i) = a(j)C. a(i+1) = a(j)D . a(i) a(j) ThenIf a(i) a(j+1) Thentemp = a(i)temp = a(j)a(i) = a(j)a(j) = a(i)a(j) = tempa(i) = tempEnd IfEnd If Fori = 1 To 9 Fori = 1 To 9For j = i + 1 To 10For j = i + 1 To 10If a(i) a(j) ThenIf a(i) a(j) Thena(i) = a(i) + a(j)a(j) = a(i) + a(j)a(j) = a(i) - a(j)a(i) = a(j) - a(i)a(i) = a(i) - a(j)a(j) = a(j) - a(i)End IfEnd IfA.B.C.D.(58)以下正确的语句组合是(58)。For i = 2 To x/2For i = 2 To x - 1If x Mod i = 0 Then Exit ForNext i prime = TrueIf x Mod i = 0 Then prime =Next i prime = True=FalseFor i = 2 To Sqr(x)If x Mod i = 0 ThenExit FunctionEnd IfNext iprime = TrueFor i = 2 To x-1If x Mod i = 0 Then Exit ForNext iIf i=x Then prime = TrueA.B.C.D.2、文本框1中有小写字母和数字混合的字符串,编程将其中的数字筛选出来,并求出它们的平均值显示在文本框 2中,结果必须保留两位有效位, 对第3位四舍五入。(59)下面代码段能实现功能的是:(59)A .只有可以B. 都可以 C.只有可以 D.都可以If str2 Thenk = k + 1ReDim Preserve num(k) num(k) = Val(str2) str2 =End IfIf str2 = Thenk = k + 1ReDim Preserve num(k) num(k) = Val(str2) str2 =End IfIf str2 ThenReDim Preserve num(k) num(k) = Val(str2) k = k + 1 str2 =End IfIf str2 Thenk = k + 1ReDim num(k) num(k) = Val(str2) str2 =End If(60)下面几种输出语句中,可以实现输出要求的有(60)Private Sub Command1_Click()Dim str1 As String, str2 As String, st As String, num() As Integer, i As Integer, k As Integer, s As Singlestr1 = Text1For i = 1 To Len(st st = Mid(str1, i, 1)If st = 0 And st = a And st = z Then 请在(59)选项中选择正确的程序段End IfNext iIf str2 Thenk = k + 1ReDim Preserve num(k) num(k) = Val(str2)End IfFori = 1 To ks = s + num(i)Next i请在(60)选项中选择正确的语句End Sub Text2.Text = Format(s / k, #.00) Text2.Text = Format(s / k, 0.#) Text2.Text = Int(100*(s / k+0.005)/100 Text2.Text = Fix(100*(s / k+0.005)/100A.1个 B. 2个C.3个D. 4个参考答案基本概念(1-25)(每小题1分,共25分)ABCBA DBDAA DDBCC BADDB BCBDA二、运行结果(26-40)(每小题2分,共30分)BACAC BBCDB ACABD三、完善程序(41-55)(每小题2分,共30分)DBDAC ABCDB BADBA四、编程题( 56-60)(每小题3分,共15分)ADDAC
展开阅读全文