# APCS 觀念題 - 流程控制 ###### tags: `APCS` ## 第 1 題 給定下方程式,當程式執行完後,輸出結果為何?(函式 `f(a)` 回傳小於浮點數 `a` 的最大整數,但是回傳型態仍為浮點數。) ```c int main() { float x = 10, y = 3; if ((0.5 * x / y - f(0.5 * x / y)) == 0.5) { printf("%f\n", f(0.5 * x / y) - 1); } else if ((0.5 * x / y - f(0.5 * x / y)) < 0.5) { printf("%f\n", f(0.5 * x / y)); } else printf("%f\n", f(0.5 * x / y) + 1); return 0; } ``` (A) 0.000000 (B) 1.000000 \(C\) 1.666667 (D) 2.000000 <!-- D --> ## 第 2 題 下方程式執行過後所輸出數值為何? ```c void main() { int count = 10; if (count > 0) { count = 11; } if (count > 10) { count = 12; if (count % 3 == 4) { count = 1; } else { count = 0; } } else if (count > 11) { count = 13; } else { count = 14; } if (count) { count = 15; } else { count = 16; } printf("%d\n", count); } ``` (A) 11 (B) 13 \(C\) 15 (D) 16 <!-- D --> ## 第 3 題 下方 `switch` 敘述程式碼可以如何以 `if-else` 改寫? ```c switch (x) { case 10: y = 'a'; break; case 20: case 30: y = 'b'; break; default: y = 'c'; } ``` (A) ```c if (x == 10) y = 'a'; if (x == 20 || x == 30) y = 'b'; y = 'c'; ``` (B) ```c if (x == 10) y = 'a'; else if (x == 20 || x == 30) y = 'b'; else y = 'c'; ``` \(C\) ```c if (x == 10) y = 'a'; if (x >= 20 && x <= 30) y = 'b'; y = 'c'; ``` (D) ```c if (x == 10) y = 'a'; else if(x >= 20 && x <= 30) y = 'b'; else y = 'c'; ``` <!-- B --> ## 第 4 題 下方是依據分數 `s` 評定等第的程式碼片段,正確的等第公式應為: * 90 ~ 100 判為 A 等 * 80 ~ 89 判為 B 等 * 70 ~ 79 判為 C 等 * 60 ~ 69 判為 D 等 * 0 ~ 59 判為 F 等 這段程式碼在處理 0 ~ 100 的分數時,有幾個分數的等第是錯的? ```c if (s >= 90) { printf("A \n"); } else if (s >= 80) { printf("B \n"); } else if (s > 60) { printf("D \n"); } else if (s > 70) { printf("C \n"); } else { printf("F\n"); } ``` (A) 20 (B) 11 \(C\) 2 (D) 10 <!-- B --> ---- ## 解答 |1|2|3|4|5| |-|-|-|-|-| |D|D|B|B|-| [<< APCS 觀念題 - 運算式](https://hackmd.io/@kaeteyaruyo/APCS-concept-expression) | [目錄](https://hackmd.io/@kaeteyaruyo/APCS-concept-index) | [APCS 觀念題 - 迴圈 >>](https://hackmd.io/@kaeteyaruyo/APCS-concept-loop)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up