2007年秋江蘇省計算機等級考試二級VB考試真題及答案_第1頁
2007年秋江蘇省計算機等級考試二級VB考試真題及答案_第2頁
2007年秋江蘇省計算機等級考試二級VB考試真題及答案_第3頁
已閱讀5頁,還剩7頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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創(chuàng)建一個名為“文件”的菜單項,使其可用創(chuàng)建一個名為“文件”的菜單項,使其可用 alt+falt+f 方式訪問,則在菜單方式訪問,則在菜單編輯器的標題文本框中應輸入編輯器的標題文本框中應輸入a.a.文件文件($f)b.($f)b. 文件文件(&f)(&f) c. c. 文件文件(#f)d.(#f)d. 文件文件(%f)(%f)2323數(shù)學表達式的數(shù)學表達式的 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 語句可以重新定義數(shù)組的維數(shù)語句可以重新定義數(shù)組的維數(shù)b.b. 使用不帶關鍵字使用不帶關鍵字 preservepreserve 的的 redimredim 語句可以改變數(shù)組各維的上、下界語句可以改變數(shù)組各維的上、下界c.c. 使用不帶關鍵字使用不帶關鍵字 preservepreserve 的的 redimredim 語句可以改變數(shù)組的數(shù)據(jù)類型語句可以改變數(shù)組的數(shù)據(jù)類型d.d. 使用不帶關鍵字使用不帶關鍵字 preserveprese

5、rve 的的 redimredim 語句可以對數(shù)組中的所有元素進行初語句可以對數(shù)組中的所有元素進行初始化始化2525下列下列是合法的變量名。是合法的變量名。a. absb. -a1c. cdc dd. abc_10a. absb. -a1c. cdc dd. abc_102626要向文件要向文件 data.txtdata.txt 添加數(shù)據(jù),正確的文件打開命令是添加數(shù)據(jù),正確的文件打開命令是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. 以下對數(shù)組參數(shù)的說明中,錯誤的是以下對數(shù)組參數(shù)的說明中,錯誤的是a.a.在過程中可以用在過程中可以用 dimdim 語句對形參數(shù)組進行聲明語句對形參數(shù)組進行聲明b.b.形參數(shù)組只能按地址傳遞形參數(shù)組只能按地址傳遞c.c.實參為動態(tài)數(shù)組時,可用實參為動態(tài)數(shù)組時,可用

7、redimredim 語句改變對應形參數(shù)組的維界語句改變對應形參數(shù)組的維界d.d.只需把要傳遞的數(shù)組名作為實參,即可調用過程只需把要傳遞的數(shù)組名作為實參,即可調用過程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能夠將任意一個兩位整數(shù)能夠將任意一個兩位整數(shù) x x 的個位數(shù)與十位數(shù)對調(例如將的個位數(shù)與十位數(shù)對調(例如將 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執(zhí)行下面程序,單擊執(zhí)行下面程序,單擊 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. 執(zhí)行以下程序,單擊執(zhí)行以下程序,單擊 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. 執(zhí)行下面的程序,單擊執(zhí)行下面的程序,單擊 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執(zhí)行下面的程序,連續(xù)三次單擊命令按鈕執(zhí)行下面的程序,連續(xù)三次單擊命令按鈕 command1command1 之后,之后,a a 數(shù)組共數(shù)組共有有 (9 9) 個元素;個元素; 數(shù)組元素數(shù)組元素 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執(zhí)行下面的程序,單擊執(zhí)行下面的程序,單擊 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本程序的功能是利用無窮級數(shù)求本程序的功能是利用無窮級數(shù)求 cos(x)cos(x)的近似值。已知:當?shù)诘慕浦?。已知:當?shù)?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 方陣的范數(shù)。方陣的數(shù)值是隨機生成的方陣的范數(shù)。方陣的數(shù)值是隨機生成的-20-202020 之間的整數(shù)。方陣范數(shù)是指方陣各列元素的絕對值之和中的最大的之間的整數(shù)。方陣范數(shù)是指方陣各列元素的絕對值之和中的最大的數(shù)值。數(shù)值。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、下面程序的功能是,找出僅由數(shù)字、下面程序的功能是,找出僅由數(shù)字 1 1、2 2、3 3、4 4 組成的組成的 4 4 位素數(shù),要求每位素數(shù),要求每個素數(shù)由個素數(shù)由 4 4 個不同數(shù)字組成。個不同數(shù)字組成。 算法提示:算法提示: 函數(shù)函數(shù) validatevalidate 用于驗證一個用于驗證一個 4 4 位數(shù)位數(shù)是否由是否由 4 4 個不同數(shù)字組成。個不同數(shù)字組成。 在函數(shù)中用在函數(shù)中用 a a 數(shù)組的各個元素分別對應數(shù)字數(shù)組的各個元素分別對應數(shù)字 0 09 9,只要某數(shù)字出現(xiàn)在四位數(shù)中,無論幾次,均將該數(shù)字對

29、應的數(shù)組元素值置為只要某數(shù)字出現(xiàn)在四位數(shù)中,無論幾次,均將該數(shù)字對應的數(shù)組元素值置為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下面程序的功能是:下面程序的功能是:首先生成一個由小到大已排好序的整數(shù)數(shù)組,首先生成一個由小到大已排好序的整數(shù)數(shù)組,再輸入再輸入一個數(shù)據(jù),一個數(shù)據(jù),單擊“插入”按鈕,單擊“插入”按鈕,會自動把這個數(shù)據(jù)插入到原數(shù)組適當?shù)奈恢?,會自動把這個數(shù)據(jù)插入到原數(shù)組適當?shù)奈恢茫⒈3謹?shù)組的有序性。并保持數(shù)組的有序性。

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論