問題詳情

26 執行下列 C 程式後,產生的輸出為何?


(A) four one four two four
(B) four one two three four two three four
(C) one two three four two three four three four
(D) four one two three four two three four three four

參考答案

答案:B
難度:困難0.371
書單:沒有書單,新增

用户評論

努力考上公務員】評論

int main(){    int i;    for(i=0;i<3;i++){        switch(i){            case 0:break;            case 1:printf("one");            case 2:printf("two");            case 3:printf("three");        }        printf("four");    }    return 0;}這題有陷阱case 0 有break 所以會跳出functioncase 1 沒有 break印出結果為 four所以會往下個case 跑直到找到 break所以印出 one two three fourcase 2 也沒有 break 或 結束印出結果為  two three four所以會往下個case 跑直到找到 break 或 結束fouronetwothreefourtwothreefour