練習卷下載
一、單選題:(每3分,共12題) 36%
01( B3 )執行下列程式(一)結果輸出幾個G?
02( C75 )執行下列程式(二)結果輸出S=?
03( B6 )執行下列程式(三)結果輸出S=?
'
程式(一) 4-9頁-1
For
X = 15 To 2 Step -2
Label1.Text &= "G"
X = X - 3
Next
X
|
'
程式(二) 4-9頁-2
Dim
S = 0
For
X = 5 To 20 Step 3
S = S + X
Next
Label1.Text
= "S = " & S
|
'
程式(三) 4-9頁-3
Dim
S = 1, R = 1
For
X = 2 To 15
S = S + X * R
R = R * (-1)
Next
Label1.Text
= "S = " & S
|
04( A3 )執行下列程式(四) 結果輸出S=?
05( D6 )執行下列程式(五)結果輸出幾個*?
06( D20 )執行下列程式(六)結果輸出A+S=?
'
程式(四) 4-9頁-4
Dim
S = 0
For
X = 2 To 7
S = S + (X Mod 2)
Next
Label1.Text
= "S = " & S
|
'
程式(五) 4-9頁-5
Dim
A = 5, B = 13
For
A = 2 To B Step 1
If (A Mod 2 = 0) Then
Label1.Text &= "*"
End If
Next
|
'
程式(六)
Dim
A = 3, B = 7, S = 6
For
A = 2 To B Step 2
S = S + 2
Next
A
Label1.Text
= "A+S = " & A + S
|
07( B6 )執行下列程式(七) 結果輸出S=?
08( c30 ) 執行下列程式(八) 結果輸出T=?
09( d15 ) 執行下列程式(九) 結果輸出S=?
'
程式(七)
Dim
A = 13, B = 5, S = 6
For
A = 2 To B Step -2
S = S + 2
Next
A
Label1.Text
= " S = " & S
|
' 程式(八)
Dim T = 0
For k =3
To 12 Step 3
T = T + k
Next
Label1.Text
= "T = " & T
|
' 程式(九)
Dim S = 0
For K = 2
to 16
S = S + (K Mod 3)
Next
K
Label1.Text
= "S = " & S
|
10( C )For...Next敘述,若要中途跳出迴圈使用? (A) Exit Loop (B) Quit
For (C) Exit For (D) Quit Next
11( C )有關For...Next敘述,下列何者正確? (A)Next敘述後的控制變數,不可省略不寫 (B)增加值只能為正值
(C)若增加值為1,則可省略不寫Step (D)增加值需小於初始值
12( D )有關For...Next敘述,下列何者正確? (A)若省略Step,則增加值為0 (B)若增加值為正,則需初值小於
等於0 (C)若終值為負,則增加值需為負 (D)控制變數A,若初值1,增值2,終值為5,寫成 For A=1 To
5 Step 2
二、填充題:每格2分,共21格(42%)
'
程式(十)
Dim
X,C,S As Integer
For
X=3 To 13 Step 2
C=C+1 : S=S+X
Next
X
問X=_15__、C=_6__、S=__48___
|
' 程式(十一)
Dim
X,C,S As Integer
For
X=18 To 12 Step - 3
C=C+1 : S=S+X
Next
X
問X=_9__、C=_ 3__、S=___45___
|
' 程式(十二)
Dim
X,C,S As Integer
For
X=32 To 15 Step - 5
S=S+X : C=C+1
Next
X
執行後,C=__4_,X=__12__,S=__98___
|
'
程式(十三)
Dim
C,X,Y,S As Integer
For
X=4 To 15 Step 3
For Y=2 To 7 Step 2
C=C+1 : S=S+Y
Next Y
Next
X
問X=_16_,Y=_8_,C=_12_,S=__48__
|
'
程式(十四)
Dim
C,X,Y,S As Integer
For
X=2 To 13 Step 4
For Y=X+1 To 9 Step 3
C=C+1 : S=S+Y
Next Y
Next
X
問X=_14_,Y=_11_,C=_4_,S=__25__
|
'
程式(十五)
Dim
C,X,Y,S As Integer
For
X=16 To 1 Step - 5
For Y=11 To X Step -3
C=C+1 : S=S+X+Y
Next Y
Next
X
問X=_-4_,Y=_-1_,C=_7_,S=__83__
|
三、陣列宣告:(每格1.5分) ,寫元素個數、及共佔用記憶體(Bytes)
{本題不作答的話,第1大題配分調整為每題4.8分}
宣告
|
元素個數
|
佔用記憶體(Bytes)
|
1、Dim A(3,4) AS Short
|
(3+1)*(4+1) = 20
|
2* 20 = 40
|
2、Dim B(2,3,2) AS Byte
|
(2+1)* (3+1)*(2+1) =
36
|
1* 36 = 36
|
3、Dim C(5) AS Long
|
(5+1) = 6
|
8* 6 = 48
|
4、Dim D(7) AS Integer
|
(7+1) = 8
|
4* 8 = 32
|
5、Dim Ee(6,3) AS Single
|
(6+1)*(3+1) = 28
|
4*28 = 112
|
6、Dim F(1,3,2) AS Double
|
(1+1)* (3+1)*(2+1) =
24
|
8* 24 = 192
|
7、Dim G(3,2,3) AS Date
|
(3+1)* (2+1)* (3+1)
= 48
|
8* 48 = 384
|
(二) 依以上的宣告做答:(今天練習)
8、問A.Length = ___20____ 9、問Ubound(A,2) = ____4____
10、問Ubound(Ee,2) = ___3_____ 11、問Lbound(F,1)
= ___0______
四、Do迴圈練習
01( A )執行下列程式(一) 結果輸出S=? (A) 10 (B) 18 (C) 23
(D) 30
02( A )執行下列程式(二) 後,何者正確? (A) A=7 (B) S=12
(C) S=5 (D) A=3
03( B )執行下列程式(三)結果輸出S=? (A) - 25 (B) - 12 (C) 10
(D) 20
'
程式(一) 4-27頁-5
Dim
A = 1, S = 0
Do
While A < 5
If A Mod 2 = 1 Then
S = 3 * S
Else
S = S + A
End If
A = A + 1
Loop
Label1.Text
= "S = " & S
|
' 程式(十四)自訂練習
Dim
A = 3, B = 2, S = 5
Do While S < 13
S = S + A
A = A + B
Loop
Label1.Text = "A,S = " & A
& "," & S
|
'
程式(三) 4-26頁-1
Dim
A = 5, B = 10, S = 0
Do
While A >= -1
S = S + 1
B = B - 3
A = A - 3
Loop
Label1.Text
= "A*B*S = " & A * B * S
|
04( A )執行下列程式(四) 結果輸出S=? (A) 4 (B) 8 (C) 12
(D) 15
05( C )執行下列程式(五) 結果輸出B=? (A) 5 (B) 7 (C) 11
(D) 15
06( B )執行下列程式(六) 結果輸出B=? (A) 0 (B) 6 (C) 21
(D) 30
'
程式(七) 4-26頁-2
Dim
A = 15, S = 0
Do
If A Mod 3 = 0 Then
S = S + 1
End If
A = A - 1
Loop
While A > 3
Label1.Text
= "S = " & S
|
'
程式(八) 4-27頁-3
Dim
A = 1, B = 5
While B < 10
B = B + 2 * A
A = A + 1
End While
Label1.Text
= "B = " & B
|
'
程式(九) 4-27頁-4
Dim
A = 42, B = 30, C = 1
Do
While C <> 0
C = A Mod B
If C <> 0 Then
A = B
B = C
End If
Loop
Label1.Text
= "B = " & B
|
07( A )Do...Loop敘述,若要中途跳出迴圈使用? (A) Exit Do (B) Quit Do
(C) Exit Loop (D) Quit Loop
08( B ) Do...Loop敘述,下列何者有誤? (A) 前測式可能執行0次 (B) 前測式最少會執行1次
(C) 後測式最少會執行1次 (D) Do … Loop While(條件)
是後測式
補充函數:Int , Abs , Sign, Sqrt, Fix, Cint ,
Year , Month , Day , Now, Hour, Minute, Second,例題如下
會考選擇
01( 1 )執行VB的內建函數Math.SIGN(2.56)後,其值為何?
02( -1 )執行VB的內建函數Math.SIGN(-2.56)後,其值為何?
03( 2.5
)執行VB的內建函數Math.SQRT(
6.25 )後,其值為何?
04( -7
)執行VB的內建函數INT(-6.25)後,其值為何?
05( 2
)執行VB的內建函數INT(2.56)後,其值為何?
05( 2
)執行VB的內建函數Fix(2.56)後,其值為何?
06( 2.56 )執行VB的內建函數Math.ABS(-2.56)後,其值為何?
07( 6.25 )執行VB的內建函數Math.ABS(6.25)後,其值為何?
18( 2019
)執行VB的內建函數Year(Now)後,其值為何?
19( 1
)執行VB的內建函數Month(Now)後,其值為何?
10( 13 )執行VB的內建函數Hour(#1:23:45 PM#)後,其值為何?
11( 23 )執行VB的內建函數Minute(#1:23:45 PM#)後,其值為何?
12( 45 )執行VB的內建函數Second(#1:23:45 PM#)後,其值為何?