2007年秋江苏省计算机等级考试二级VB考试真题及答案_第1页
2007年秋江苏省计算机等级考试二级VB考试真题及答案_第2页
2007年秋江苏省计算机等级考试二级VB考试真题及答案_第3页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、20072007 年秋江苏省计算机等级考试二级年秋江苏省计算机等级考试二级 vbvb 考试真题及答案考试真题及答案第二部分第二部分 visual basic visual basic 程序设计程序设计一、选择题(用答题卡答题,答案依次填在一、选择题(用答题卡答题,答案依次填在 21213030 答题号内)答题号内)2121下列语句中,正确的是下列语句中,正确的是a. text1.setfocusb. form1.cleara. text1.setfocusb. form1.clear c. label1.setfocusd. c. label1.setfocusd.list1.clslist1

2、.cls2222创建一个名为“文件”的菜单项,使其可用创建一个名为“文件”的菜单项,使其可用 alt+falt+f 方式访问,则在菜单方式访问,则在菜单编辑器的标题文本框中应输入编辑器的标题文本框中应输入a.a.文件文件($f)b.($f)b. 文件文件(&f)(&f) c. c. 文件文件(#f)d.(#f)d. 文件文件(%f)(%f)2323数学表达式的数学表达式的 vbvb 算术表达式为算术表达式为a. sin(27) + sqr(x + exp3)/(x + y)a. sin(27) + sqr(x + exp3)/(x + y)b. sin(27 * 3.14159

3、 / 180) + sqr(x + exp(3) / abs(x + y)b. sin(27 * 3.14159 / 180) + sqr(x + exp(3) / abs(x + y)c. sin(27 * 3.14159 / 180) + sqr(x + e 3) / abs(x + y)c. sin(27 * 3.14159 / 180) + sqr(x + e 3) / abs(x + y)d. sin(27 * pi / 180) + sqr(x + exp(3) / abs(x + y)d. sin(27 * pi / 180) + sqr(x + exp(3) / abs(x +

4、 y)2424以下说法不正确的是以下说法不正确的是 24 24。a.a. 使用不带关键字使用不带关键字 preservepreserve 的的 redimredim 语句可以重新定义数组的维数语句可以重新定义数组的维数b.b. 使用不带关键字使用不带关键字 preservepreserve 的的 redimredim 语句可以改变数组各维的上、下界语句可以改变数组各维的上、下界c.c. 使用不带关键字使用不带关键字 preservepreserve 的的 redimredim 语句可以改变数组的数据类型语句可以改变数组的数据类型d.d. 使用不带关键字使用不带关键字 preserveprese

5、rve 的的 redimredim 语句可以对数组中的所有元素进行初语句可以对数组中的所有元素进行初始化始化2525下列下列是合法的变量名。是合法的变量名。a. absb. -a1c. cdc dd. abc_10a. absb. -a1c. cdc dd. abc_102626要向文件要向文件 data.txtdata.txt 添加数据,正确的文件打开命令是添加数据,正确的文件打开命令是a.open data1.txt for output as #1a.open data1.txt for output as #1 b.open data1.txt for input as #1 b.op

6、en data1.txt for input as #1c.open data1.txt for append as #5c.open data1.txt for append as #5 d.open data1.txt for write as #5 d.open data1.txt for write as #527.27. 以下对数组参数的说明中,错误的是以下对数组参数的说明中,错误的是a.a.在过程中可以用在过程中可以用 dimdim 语句对形参数组进行声明语句对形参数组进行声明b.b.形参数组只能按地址传递形参数组只能按地址传递c.c.实参为动态数组时,可用实参为动态数组时,可用

7、redimredim 语句改变对应形参数组的维界语句改变对应形参数组的维界d.d.只需把要传递的数组名作为实参,即可调用过程只需把要传递的数组名作为实参,即可调用过程2828设设a a = = 3 3,b b = = 2 2,c c = = 1 1,运行,运行printprint a a b b c c 的结果是的结果是 28 28。a. true b. false c. 1a. true b. false c. 1 d. d. 出错出错2929能够将任意一个两位整数能够将任意一个两位整数 x x 的个位数与十位数对调(例如将的个位数与十位数对调(例如将 7878 转换为转换为8787)的表达

8、式是)的表达式是 29 29。 val(right(x, 1) & left(x, 1) val(right(x, 1) & left(x, 1) val(right(str(x), 1) & left(str(x), 1) val(right(str(x), 1) & left(str(x), 1) val(right(cstr(x), 1) & left(cstr(x), 1) val(right(cstr(x), 1) & left(cstr(x), 1) val(mid(x, 2, 1) + mid(x, 1, 1) val(mid(x,

9、 2, 1) + mid(x, 1, 1)a. a. b. b. c. c. d. d. 3030下列下列是正确的是正确的 vbvb 常量。常量。a. d-6 b. e-6 c. 5d d. 5e-6a. d-6 b. e-6 c. 5d d. 5e-6二、填空题(请将答案填写在答题纸的相应答题号内,每个答案只占一行)二、填空题(请将答案填写在答题纸的相应答题号内,每个答案只占一行)1 1执行下面程序,单击执行下面程序,单击 command1command1,则窗体上显示的第一行,则窗体上显示的第一行是是(1 1),第二行是,第二行是(2 2),第三行,第三行是是(3 3)。option ex

10、plicitoption explicitprivate sub command1_click()private sub command1_click() dim a as string, i as integer dim a as string, i as integer dim x as string, z as string dim x as string, z as string a = iamstudent a = iamstudent i = instr(5, a, d) i = instr(5, a, d) do do x = mid(a, i, 3) x = mid(a, i,

11、 3) z = right(x, 1) z = right(x, 1) z = ucase(x & z) z = ucase(x & z) i = i - 2 i = i - 2 print z print z loop until i = 1 loop until i = 1end subend sub2.2. 执行以下程序,单击执行以下程序,单击 command1command1,则在,则在 picture1picture1 上显示的第一行上显示的第一行是是(4 4),第二行是,第二行是(5 5),第三行,第三行是是(6 6)。option explicitoption e

12、xplicitprivate sub command1_click()private sub command1_click() dim a(3, 3) as integer, i as integer, j as integer dim a(3, 3) as integer, i as integer, j as integer dim k as integer dim k as integer i = 3 : j = 2 : a(i, j) = 1 : k = 1 i = 3 : j = 2 : a(i, j) = 1 : k = 1 do until k 9 do until k 9 k

13、= k + 1 k = k + 1 if i + 1 3 and j + 1 3 and j + 1 = 3 then i = 1 : j = j + 1 i = 1 : j = j + 1 elseif i + 1 3 then elseif i + 1 3 then i = i + 1 : j = 1 i = i + 1 : j = 1 elseif i + 1 3 and j + 1 3 then elseif i + 1 3 and j + 1 3 then i = i - 1 i = i - 1 elseif i + 1 = 3 and j + 1 = 3 and a(i + 1,

14、j + 1) elseif i + 1 = 3 and j + 1 = 3 and a(i + 1, j + 1) 0 then0 then i = i - 1 i = i - 1 else else i = i + 1 : j = j + 1 i = i + 1 : j = j + 1 end if end if a(i, j) = k a(i, j) = k loop loop for i = 1 to 3 for i = 1 to 3 for j = 1 to 3 for j = 1 to 3 picture1.print a(i, j) picture1.print a(i, j) n

15、ext j next j picture1.print picture1.print next i next iend subend sub3.3. 执行下面的程序,单击执行下面的程序,单击 command1command1,则窗体上第一行显示的,则窗体上第一行显示的是是(7 7),第二行显示的是,第二行显示的是(8 8)。option explicitoption explicitdim x as integerdim x as integerprivate sub command1_click()private sub command1_click() dim y as integer d

16、im y as integer x = 10 : y = 2 x = 10 : y = 2 call process(y) call process(y) print x, y print x, y call process(y) call process(y) print x, y print x, yend subend subprivate sub process(n as integer)private sub process(n as integer) dim y as integer dim y as integer if n 0 then if n 0 then x = x -

17、n x = x - n y = x y = x else else x = x + n x = x + n y = x + 2 y = x + 2 end if end if n = -n n = -nend subend sub4 4执行下面的程序,连续三次单击命令按钮执行下面的程序,连续三次单击命令按钮 command1command1 之后,之后,a a 数组共数组共有有 (9 9) 个元素;个元素; 数组元素数组元素 a(2)a(2)的值是的值是(1010) , a(4)a(4)的值是的值是(1111)option explicitoption explicitoption base

18、1option base 1private sub command1_click()private sub command1_click() static a() as integer, n as integer static a() as integer, n as integer dim i as integer, k as integer dim i as integer, k as integer k = n k = n n = n + 2 n = n + 2 redim preserve a(n) redim preserve a(n)。 for i = k + 1 to n for

19、 i = k + 1 to n a(i) = i * n + 1 a(i) = i * n + 1 next i next i for i = 1 to n for i = 1 to n print a(i) print a(i) next i next i print printend subend sub5 5执行下面的程序,单击执行下面的程序,单击 command1command1,在窗体界面上显示的第一行,在窗体界面上显示的第一行是是(1212), 第二行是第二行是 (1313), 第三行第三行 (1414), 第四行是第四行是option explicitoption explici

20、tprivate sub command1_click()private sub command1_click() dim a as integer, b as integer, i as integer dim a as integer, b as integer, i as integer i = 1218 i = 1218 a = i 100 a = i 100 b = i mod 100 b = i mod 100 if b 0 then if b 0 then print a print a print b print b print lcd(a), (b) a b print lc

21、d(a), (b) a b print lcd(a, b) a b print lcd(a, b) a b end if end ifend subend sub1515)。(private function lcd(x as integer, y as integer) as integerprivate function lcd(x as integer, y as integer) as integer dim d as integer dim d as integer if x y then if x y then d = x : x = y : y = d d = x : x = y

22、 : y = d end if end if d = x d = x do do if x mod y = 0 then if x mod y = 0 then lcd = x lcd = x exit do exit do else elsex = x + dx = x + d end if end if loop loopend functionend function6 6本程序的功能是利用无穷级数求本程序的功能是利用无穷级数求 cos(x)cos(x)的近似值。已知:当第的近似值。已知:当第 n n 项的绝项的绝对值小于等于对值小于等于 10-710-7,计算终止。,计算终止。opti

23、on explicitoption explicitprivate sub command1_click()private sub command1_click() dim x as single, n as integer, sum as single dim x as single, n as integer, sum as single dim a as single dim a as single x = text1 x = text1(1616) a = 1 a = 1 n = 1 n = 1dodoa = -aa = -a a = a =(1717) sum = sum + a s

24、um = sum + a n = n + 1 n = n + 1 loop until loop until(1818) text2 = sum text2 = sumend subend sub7 7下面程序的功能是求一个下面程序的功能是求一个 4444 方阵的范数。方阵的数值是随机生成的方阵的范数。方阵的数值是随机生成的-20-202020 之间的整数。方阵范数是指方阵各列元素的绝对值之和中的最大的之间的整数。方阵范数是指方阵各列元素的绝对值之和中的最大的数值。数值。option explicitoption explicitoption base 1option base 1privat

25、e sub command1_click()private sub command1_click() dim a(4, 4) as integer dim a(4, 4) as integer dim i as integer, j as integer dim i as integer, j as integer for i = 1 to 4 for i = 1 to 4 for j = 1 to 4 for j = 1 to 4 a(i, j) = a(i, j) =(1919) picture1.print right( picture1.print right( & str(a

26、(i, j), 4) & str(a(i, j), 4) next j next j picture1.print picture1.print next i next i text1.text = text1.text =(2020)end subend subprivate function fan(a() as integer) as integerprivate function fan(a() as integer) as integer dim b(4) as integer, max as integer dim b(4) as integer, max as integ

27、er dim i as integer, j as integer dim i as integer, j as integer for i = 1 to 4 for i = 1 to 4 for j = 1 to 4 for j = 1 to 4 b(j) = b(j) =(2121) next j next j next i next i max = b(1) max = b(1) for i = 2 to 4 for i = 2 to 4 if max b(i) then max = b(i) if max b(i) then max = b(i) next i next i fan =

28、 max fan = maxend functionend function8 8、下面程序的功能是,找出仅由数字、下面程序的功能是,找出仅由数字 1 1、2 2、3 3、4 4 组成的组成的 4 4 位素数,要求每位素数,要求每个素数由个素数由 4 4 个不同数字组成。个不同数字组成。 算法提示:算法提示: 函数函数 validatevalidate 用于验证一个用于验证一个 4 4 位数位数是否由是否由 4 4 个不同数字组成。个不同数字组成。 在函数中用在函数中用 a a 数组的各个元素分别对应数字数组的各个元素分别对应数字 0 09 9,只要某数字出现在四位数中,无论几次,均将该数字对

29、应的数组元素值置为只要某数字出现在四位数中,无论几次,均将该数字对应的数组元素值置为1 1。option explicitoption explicitprivate sub command1_click()private sub command1_click() dim i as integer, flg as boolean dim i as integer, flg as boolean for i = 1234 to 4321 for i = 1234 to 4321(2222) call prime(i, flg) call prime(i, flg) if flg then if

30、flg then if validate(i) then if validate(i) thentext1 = text1 & i & vbcrlftext1 = text1 & i & vbcrlf end if end if end if end if next i next iend subend subprivate sub prime(n as integer, f as boolean)private sub prime(n as integer, f as boolean) dim k as integer dim k as integer for

31、 k = 2 to sqr(n) for k = 2 to sqr(n)(2323) next k next k f = true f = trueend subend subprivate function validate(n as integer) as booleanprivate function validate(n as integer) as boolean dim a(0 to 9) as integer, s as string, i as integer dim a(0 to 9) as integer, s as string, i as integer dim s1

32、as string * 1 dim s1 as string * 1(2424) for i = 1 to len(s) for i = 1 to len(s) s1 = mid(s, i, 1) s1 = mid(s, i, 1)(2525) next i next i if a(1) + a(2) + a(3) + a(4) = 4 then if a(1) + a(2) + a(3) + a(4) = 4 then(2626) end if end ifend functionend function9 9下面程序的功能是:下面程序的功能是:首先生成一个由小到大已排好序的整数数组,首先生成一个由小到大已排好序的整数数组,再输入再输入一个数据,一个数据,单击“插入”按钮,单击“插入”按钮,会自动把这个数据插入到原数组适当的位置,会自动把这个数据插入到原数组适当的位置,并保持数组的有序性。并保持数组的有序性。

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论