2018年2月7日 星期三

計概15-03基本資料型態、常數、變數與運算式-其他試題

【技藝競賽試題】

D01.下列哪一個變數的名稱不符合Basic的命名規則? (A)a12ab (B)My_Name (C)smile (D)loop[96技競]

Loop是保留字

 

D02.Basic中,若變數資料未經宣告就使用,則會將其內定為何種資料型態? (A)Integer (B)Boolean (C)String (D)Variant[96技競VB6]

 

B03.Basic程式語言的邏輯運算中,Print 7 < 9 Xor ((20 Mod 3) = 2)的邏輯值是 (A)True (B)False (C)1 (D)2[97技競VB6]

7 < 9 Xor ((20 Mod 3) = 2) = 7 < 9 Xor (2 = 2) = 7 < 9 Xor T = T Xor T = F

 

D04.一邏輯運算式為"a < 60 And b < 60 Or c > 60 And d > 60",則下列何種情況,可使其值為"(True)" (A)a = 100, c = 0, b = d = 60 (B)a = b = 60, c = d = 59 (C)a = b = c = d = 60 (D)a = b = c = d = 59[97技競]

59 < 60 And 59 < 60 Or 59 > 60 And 59 > 60 = T And T Or F And F = T Or F = T

 

C05.I = 3J = 10K = 8,以下之邏輯運算式何者之運算結果為真(true) (A)I + K <= J (B)(I < J) AND NOT (J > K) (C)((I < K) OR (J > K)) AND (K >=0) (D)NOT ((I > J) OR (K > I))[97技競]

(A)3 + 8 <= 10 11 <= 10 F

(B)(3 < 10) And Not (10 > 8) T And Not T T And F F

(C)((3 < 8) Or (10 > 8)) And (8 >=0) (T Or T) And T T And T T

(D)Not ((3 > 10) Or (8 >3)) Not (F Or T) NOT (T) F

 

B06.Visual Basic程式中執行Print "Time:" & #8:8:8#,則輸出的資料為 (A)Time:& #8:8:8:8# (B)Time:AM 08:08:08 (C)Time:PM 08:08:08 (D)Time:AM 8:8:8[98技競VB6]

 

A07.一個邏輯閘,若有任一輸入端為1時,其輸出0,則此邏輯閘為 (A)NOR (B)NAND (C)AND (D)OR閘。[98技競]

 

D08.Visual Basic程式中執行Print Not (3 ^ 4 = 81) Or (12 <> 3 * 4),則輸出的資料為 (A)1 (B)True (C)-1 (D)False[98技競VB6]

Not (3 ^ 4 = 81) Or (12 <> 3 * 4) = Not (81 = 81) Or (12 <> 12) = Not (T) Or F = F Or F = F

 

A09.以下程式片段,可將xy值交換,請問在空白處應依序填入內容為何? (A)y = x - yx = x - y (B)x = x - yy = y + x (C)y = y + xx = x - y (D)x = x + yy = x - y[99技競VB6]

    Dim x As Integer, y As Integer

    x = 10: y = 20: x = x + y

    ______

    ______

    Print x, y

 

B10.若邏輯運算子的優先順序由高而低依序為NOTANDOR,假設三運算元XYZ的邏輯值均為假,則運算式X OR NOT Y AND Z的邏輯值為下列哪一項? (A) (B) (C)不真不假 (D)不一定。[99技競]

F Or Not F And F = F Or T And F = F Or F = F

 

B11.下列Visual Basic程式片段,Print 19 Mod 3 * 2 + 2 ^ (-1),請問其執行結果為何? (A)0 (B)1.5 (C)5.5 (D)3.5[100技競VB6]

19 Mod 3 * 2 + 2 ^ (-1) = 19 Mod 3 * 2 + 0.5 = 19 Mod 9 + 0.5 = 1 + 0.5 = 1.5

 

A12.執行以下Visual Basic程式片段,Print 49 \ 6 / 2 Mod 2 * 2,其結果為何? (A)0 (B)1 (C)4 (D)16[100技競VB6]

49 \ 6 / 2 Mod 2 * 2 = 49 \ 3 Mod 4 = 16 Mod 4 = 0

 

B13.A, B分別為八位元資料,下列八位元邏輯運算式,何者錯誤? (A)NOT(A AND B) = NOT X OR NOT B (B)NOT(NOT A OR NOT B) = A OR B (C)A AND NOT A = 00000000 (D)A OR NOT A = 11111111[100技競]

Not (Not A Or Not B) = A And B

 

【其他試題】

B01.VB中,變數敘述何者無法與AB互換? (A)T = B: B = A: A = T (B)A = B: B = A (C)SWAP A, B (D)T = A: A = B: B = T

A = 2: B = 5(B)A = B A = 5B = A B = 5

 

A02.VB中,何者有最高運算權? (A)/ (B)\ (C)Mod (D)+

算術運算符號優先順序:1.括號()2.指數^3.負號-4.*、除/5.整數除法\6.餘數Mod7.+、減-

 

D03.下列哪項運算式結果為True (A)"kitty > "kitty" (B)"XYZ" > "abc" (C)NOT 50 > 60 AND 10.A (D)5 * 3 > 40 XOR "abc" > "ABC"

(A)"kitty > "kitty" 前後相等,前者不大於後者,結果為F

(B)"XYZ" > "abc" XASCII碼為88aASCII碼為97,前者不大於後者,結果為F

(C)Not 50 > 60 And 10 = Not F And 10 = T And 10 = 10

(D)5 * 3 > 40 Xor "abc" > "ABC" = 15 > 40 Xor "abc" > "ABC" = F Xor T = T

 

B04.執行Print (2 > 20) And (3 >= 1)的結果為何 (A)True (B)False (C)2 (D)1

(2 > 20) And (3 >= 1) = F And T = F

 

B05.若「1」代表真0」代表假布林代數(Boolean Algebra)運算中下列何者為真 (A)1 AND 0 = 1 (B)0 OR 1 = 1 (C)1 AND 1 = 0 (D)1 OR 1 = 0

OR前後,只要有一個為真即為真。

(A)1 And 0 = 0(B)0 Or 1 = 1(C)1 And 1 = 1(D)1 Or 1 = 1

 

【綜合題】

算術運算

【題目1NOT 13binary code

8位元處理,13轉成2進位為00001101NOT 13的結果為11110010,因為是負數,所以要轉為2的補數,結果為00001110,答案為-14

 

【題目22 + 15 * 6 MOD 45 \ 7 =

2 + 15 * 6 MOD 45 \ 7 = 2 + 90 MOD 45 \ 7 = 2 + 90 MOD 6 = 2 + 0 = 2

 

【題目3PRINT 16.7 \ 4 - 3 * 4 MOD 5 + 10 =

16.7 \ 4 - 3 * 4 MOD 5 + 10 = 16.7 \ 4 - 12 MOD 5 + 10 = 17 \ 4 - 12 MOD 5 + 10 = 4 - 12 MOD 5 + 10 = 4 - 2 + 10 = 2 + 10 = 12

 

【題目4Print 2 + 3 * 4 ^ 2 / 2 - 12 Mod 10的結果為何?

2 + 3 * 4 ^ 2 / 2 - 12 Mod 10 = 2 + 3 * 16 / 2 - 12 Mod 10 = 2 + 48 / 2 - 12 Mod 10 = 2 + 24 - 12 Mod 10 = 2 + 24 - 2 = 26 - 2 = 24

 

【題目52 * 4 - 3 ^ 2 * (2 + 3) Mod 7

2 * 4 - 3 ^ 2 * (2 + 3) Mod 7 = 2 * 4 - 3 ^ 2 * 5 Mod 7 = 2 * 4 - 9 * 5 Mod 7 = 8 - 45 mod 7 = 8 - 3 = 5

 

【題目62 * 4 - 3 ^ 2 + (2 + 3) Mod 7

2 * 4 - 3 ^ 2 + (2 + 3) Mod 7 = 2 * 4 - 3 ^ 2 + 5 Mod 7 = 2 * 4 - 9 + 5 Mod 7 = 8 - 9 + 5 Mod 7 = 8 - 9 + 5 = -1 + 5 = 4

 

邏輯運算

【題目17 + 50 Mod 6 / 12 And Not 6 Or 7 > 4 + 5

7 + 50 Mod 6 / 12 And Not 6 Or 7 > 4 + 5 = 7 + 50 Mod 0.5 And Not 6 Or 7 > 4 + 5 = 7 + 50 Mod 0 And Not 6 Or 7 > 4 + 5 50 Mod 0,因為除以0無法執行

 

【題目22 * 3 And 4 Or Not -5 + 5 > 3

2 * 3 And 4 Or Not -5 + 5 > 3 = 6 And 4 Or Not -5 + 5 > 3 = 6 And 4 Or Not 0 > 3 = 6 And 4 Or Not False = 6 And 4 Or True = 4 Or True = -1

 

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。