2003年4月全國計算機等級考試二級QBASIC語言程式設計

一、選擇題((1)-(40)每小題1分,(41)-(50)每小題2 分,共60分)
下列各題 a) 、b)、c) 、d)四個選項中,只有一個選項是正確的,請將正確選項塗寫在
答題卡相應位置上,答在試卷上不得分。
(1) 用8位無符號二進制數能表示的最大十進制數為
a) 127 b) 128 c) 255 d) 256

(2) 在64位高檔微機中,一個字長所占的二進制位數為
a) 8 b) 16 c) 32 d) 64

(3) 在windows環境下,為了複製一個對象,在用滑鼠拖動該對象時應同時按住
a) alt鍵 b)esc鍵 c)shift鍵 d)ctrl鍵

(4) 在windows選單中,暗淡(灰色)的命令項表示該命令
a) 暫時不能用 b) 正 在執行 c) 包含下一層選單 d) 包含對話框

(5) 在dos環境下,為了得到type命令的幫助信息,正確的dos命令為
a) type b) type/h c) type/* d) type/?

(6) 下列選項中,能作為合法dos檔案名稱的是
a) anp/a.dat b) abccom c) ecd.basic d) xy+z.txt

(7) 下列敘述中正確的是
a) 在windows環境下,最大化的視窗是不能移動的
b) 在windows環境下,應用程式視窗最小化後,該應用程式暫停執行
c) 在windows環境下,只有最小化的視窗才能關閉
d) 在windows環境下,不能關閉最大化的視窗

(8) 在windows環境下,工具列中的複製按鈕是
a) 印表機圖示 b)剪刀標誌 c) 複製標誌 d) 貼上標誌

(9) 在windows98環境下,若要將整個螢幕上顯示的內容存入剪貼簿,可以按
a) ctrl+printscreen鍵 b) alt+printscree鍵
c) shift+printscreen鍵 d) printscreen鍵

(10) 目前,計算機病毒擴散最快的途徑是
a) 通過軟體複製 b) 通過網路傳播
c) 通過磁碟考貝 d) 運行遊戲軟體

(11) 在qbasic集成開發環境中,在編輯源程式後要運行程式,應按下鍵盤上的
a) f2鍵 b) f5鍵 c) enter鍵 d) end鍵

(12) 關於qbasic源程式語句中行號的說法正確的是
a) 必須有行號 b) 不允許有行號 c) 根據需要可有可無 d) 只允許有標號

(13) 在qbasic中,常量3e1的數據類型是
a) 字元串 b) 單精度實型 c) 雙精度實型 d) 整型

(14) 在下列四個式子中,非法的qbasic表達式是
a) a=abc b) 5>3+3 c) a+b=c d) 5<>5

(15) qbasic表達式3^3/3mod2的值是
a) 1 b) -1 c) 3 d) 0

(16) 在以下屬於合法的qbasic變數名是
a) x-3 b) 4y c) n$1 d) b.1

(17) 定義一個3×3的二維數組,正確的語句是
a) dim a(0 to 3,0 to 3) b)dim a(2000 to 2002,0 to 2)
c) dim a(3),a(3) d)dim a(1 to 3)

(18) 下列語句中合法的是
a) print a=atn b) print"sin(3.14)"+"cos(3.14"
c) print tab(10) "qb" d) print using"####",1234.56

(19) 在qbasic中,下列運算符優先權最高的是
a) mod b) not c) / d) ^

(20) 正確的單行自定義函式語句是
a) def fn(x)=3.14159*x^2 b) define fn(x)=3.14129*x^2
c) def fnn(x)=3.14159*x^2 d) def fnn(x)=3.14159*x^2 end

(21) 表達式int(4*rnd+1)*(int(4*rnd-1))值的範圍是
a) [0,8] b) [-1,8] c) [-3,8] d)[-4,8]

(22) 有如下程式段
const c="wang"
c$="a"
print len(c);len(c$)
其輸出結果為
a) wang a b) 4 1 c) 1 1 d) 重複定義,程式出錯

(23) 有如下程式段
a%=12.8:b!=14.5
print a%,b!
其輸出結果為
a) 12.8 4 b) 12 1 4.5 c) 12.8 15 d) 13 1 4.5

(24) 有如下程式
read a,b,c
restore k
read c,c,d
data 1,2
k: data 3,4,5
print a;b;c;d
end
a) 1 2 3 4 b) 1 2 3 5 c) 3 4 5 4 d) 1 2 4 5

(25) 以下語句中錯誤的是
a) input"x,y=";a,b b) input"x,y=",c,d
c) input, "x,y=",e,f d) input; "x,y=",g,h

(26) 實現選擇結構"如果x確程式段為
a) if x
b) if x>=y then
a=-15 a=-15
print a else a=15
end if end if
print a
c) if x>y then a=-15
d) if x>=y then go to d
a=15 a=15
print a d: a=-15
end print a
end

(27) 以下語句中正確的是
a) for 1 to 10 step 2 b) for x=1,9 step3
c) for x=10 to-10 step-10 d) for x=10 to 50 next

(28) 有如下程式
dim k as integer, y as integer
let y=3
for k=1 to 5 step-1
y=y+k
next k
print y;k
end
其輸出結為
a) 3 1 b) 4 0 c) -1 6 d) 4 1

(29) 有如下程式
dim x as integer, y as integer
for x=1 to 2
for y=0 to x=-1
print x*y
next y
next x
end
內層循環的循環體的總執行次數是
a) 1 b) 2 c) 3 d) 4

(30) 有如下程式
dim x as integer, y as integer
x=0
read y
while y<>-9999 and x<>3
if y>x then x=y
read y
wend
data-9999,9,8,3,9999
print abs(y)
end
運行後的輸出結果為
a) 9 b) -9999 c) 3 d) 9999

(31) 有如下程式
a$="12"
b$="24"
c$=b$+a$
d=val(c$)
print d100
end
運行後的輸出結果是
a) 12 b) 36 c)34 d) 24

(32) 有如下程式
for j=1 to 5
a=(a+j)mod 5
next j
print a
end
運行後的輸出結果是
a) 0 b) 5 c) 25 d) 50

(33) 當eof()函式返回的值為-1時,表示檔案指針指向檔案的
a) 開頭 b) 第一個記錄 c) 末尾 d) 最後一個記錄

(34) 有如下程式
for x=1 to 4
z=0
for y=1 to x+2
z=z+1
next y
print z;
next x
end
運行後的輸出結果是
a) 3 4 5 6 b) 4 5 6 7 c) 5 6 7 8 d) 6 7 8 9

(35) 有如下程式
def fna(x,y)=x^2+y^2
x=4
y=3
print fna(x,y)
end
運行後的輸出結果是
a) 5 b)7 c)25 d)49

(36) 有如下程式
m$="abcde"
mid$(m$,1,5)= "abcde"
print m$
end
運行後的輸出結果是
a) abcdeabcde b) abcdeabcde c) abcde d) abcde

(37) 有如下程式
for j=1 to 10
read a
if a mod 2=0 then sum=sum+a
next j
print"sum=";sum
data 1,3,6,10,15,21,28,36,45,55
end
運行後的輸出結果是
a) 55 b) 80 c) 140 d) 220

(38) 有如下程式
x=1
do
x=2*x+1
num=num+1
loop until x>100
print num,x
end
運行後的輸出的結果是
a) 6 127 b)8 127 c)127 8 d)127 8

(39) 有如下程式
sum=0
for i=1 to 9
if i<>10 then
sum=sum+1
else
sum=sum+2
end if
next i

(40) 有如下程式
m$="*"
i=1
for k=3 to 1 step -1
x$=string$(k+i,m$)
print x$
m$=m$+"*"
i=-i
next k
end
運行後的輸出結果是

a) **
 ***
 ****
b) ****
  ***
  **
c) ****
  *
  **
d) ****
  **
  ******

(41) 有如下程式
declare sub f(m%,n%,g%)
call f(87,69,g%)
print g%
end
sum f(m%,n%,g%)
a=m%
b=n%
do
c=a mod b
a=b
b=c
loop while c<>0
g%=a
end sub
運行後的輸出結果是
a) 3 b) 18 c) 69 d)87

(42) 有如下程式
input n
i=2
t=-1
do while i*i<=n
if n mod i=0 then
t=0
end if
i=i+1
loop
print t
end
運行時輸入257,輸出結果是
a) 0 b) 1 c) -1 d) 257

(43) 有如下程式
month=int(rnd*3+1)+6
select cass month
case 1 to 3
season$="first"
case 4 to 6
season$="second"
case 7 to 9
season$="third"
case else
season$="fourth"
end select
print season$
end
運行後的輸出結果是
a) first b)second c)thire d)不能確定

(44) 有如下程式
declare function f(n)
input n
print f(n)
end
function f(n)
if n=0 then f=0 else f=n+f(n-1)
end function
鍵盤輸入n運行後的輸出結果是78,則n的值是
a) 10 b)11 c)12 d)13

(45) 有如下程式
cls:screen 13:color 2
x=180:y=100:r=50
circle(x,y),50
circle(180,100),r
end
該程式在螢幕上顯示的是
a) 一個圓 b) 兩個同心圓 c) 兩個不同心的圓 d) 沒有顯示

(46) 有如下程式
screen 13
color 2
line(10,10)-(50,50)
line(50,50)-(10,90)
end
程式所畫兩條線段
a) 關於一點對稱 b) 關於一條垂直的直線對稱
c) 關於一條水平的直線對稱 d) 重合

(47) 有如下程式
for m=3 to 5
for j=1 to m-2
for k=j to 3
n=n+k
next k
next j
next m
end
運行後n的值為
a) 21 b) 25 c) 31 d) 42

(48) 有如下程式
m$="a"
n$="b"
o$=lcase$(m$)
p$=ucase$(n$)
end
運行結果是
a) a 0 b 0 b) a 0 b0 c) a 97 b 66 d) a 65 b 98

(49) 語句open"a.dat"for random as#1 len=30表示此檔案每個記錄
a)長度等於30個字元 b)長度等於30個位元組
c)長度小於或等於30個位元組 d)長度小於或等於30個字元

(50) 有如下程式
dim x(3,3)
for k=1 to 2
for j=1 to 2
if k=j then
x(k,j)=1
else
x(k,j)=0
end if
next j:next k
open"diagonal.dat"for output as#1
for k=1 to 2
print#1,x(k,1);x(k,2)
next k
close#1
end
執行程式,螢幕上顯示的結果是
a) 0 1
1 0
b) 1 0
0 1
c) 0 0
1 1
d) 沒有任何顯示

二、填空題(每空2分,共20分)
請將每空的正確答案寫在答題卡上【1】-【10】序號的橫線上,答在試卷上不得分。
(1) 用十六進制給存儲器中的位元組地址進行編號,若地址編號從000到ffff,則該存諸器的容量為【1】kb。

(2) 假設在當前盤的當前目錄下有兩個檔案a.txt和b.txt,現要將檔案b.txt合併連線到檔案a.txt的後面。若使用copy命令,則完整的命令為【2】。

(3) e-mail地址由用戶名和域名兩部分組成,這兩部分的分隔設定為【3】。

(4) 假設在當前盤當前目錄下有一個可執行程式user.ext。現要執行該程式,並要求在執行過程中將顯示輸出的結果信息存入當為【4】。

(5) 在dos環境下,表示印表機的設備檔案名稱為【5】。

(6) 數據式aeutcos(wt+v)的qbasic表達式為【6】。

(7) 常數-0.00013579的標準化的指數形式是【7】。

(8) 有如下程式
a=1357:b=246
c=len(str$(a)+str$(b))
print c
end
運行後,輸出的值是【8】。

(9) 四個字元串"xab"、""xyz"、"def"及"de"中最大者為【9】。

(10) 有如下程式
for j=1 to 11
j=j+1
if j mod 4=0 then n=n+1
next j
print"n=";n
end
運行後,輸出的值是【10】。

(11) 有如下程式
x=5:y=-20
if not x>0 then
x=y-3
else
y=y+3
end if
print x-y;y-x
end
運行後的輸出結果是【11】。

(12) 設a=2,b=3,c=4,d=5,表達式3>2*b or a=c and b<>c or c>d的值是【12】。

(13) 有如下程式
for i=1 to 5
for x=i to 5 step 1
if i=2 and x<5 then print"*";
next x
next i
end
運行後輸出的結果是【13】。

(14) 隨機生成100個-500到500間的整數(含-500和500),並找出其中第k大的數。請在【14】、【15】處填入適當內容將程式補充完整。
dim a(100)
input k
for i=1 to 100
a(i)=int(【14】*rnd)-500:print a(i);
next i
print
for i=1 to k
for j=i+1 to 100
if【15】then swap a(i),a(j)
next j
next i
print"a(";k;")=";a(k);
end

(15) 有如下程式
dim i as integer,x as integer
x=1:y=1:i=1
do while i<4
f=x+y
x=y
y=f
print f
i=i+1
loop
end
運行後的輸出的結果是【16】。

(16) 有如下程式
dim tel(10)as string*8
for i=1 to 4
read tel(i)
next i
for i=1 to 4
if left$(tel(i),1)="2"then
tel(i)="6"+tel(i)
else
tel(i)=tel(i)+"9"
end if
next i
print tel(1),tel(2)
data 6543210,2345678,2457788,8237777
end
運行後輸出的結果是【17】。

(17) 下面的程式從鍵盤輸入一個正整數n,計算並輸出比n小,並且與n互素的數的個數。(兩個數互素是指它們的最大公約數等於1)
declare function gcd(a,b)
input n
phi=1
for i=2 to n-1
if gcd(n,i)=1 then phi=【18】
next i
end
function gcd(a,b)
if b=0 then
tmp=【19】
else
if b=1 then tmp=1 else tmp=gcd(b, 【20】)
endif
gd=tmp
end function
運行後,輸出的值是