Examly題庫立即開始練習
2 類科共用卷
普考-電信工程普考-電子工程
計算機概要10828單選題

執行下列 C 程式後,產生的輸出為何? #include <stdio.h> int main(void){ int a[10]={0},i; a[0]=0; for(i=0; i<10; i++){ a[i+1]=a[i]+i*3; if(a[i]<10) continue; printf("%d ", a[i]); } return 0; }

A0 0 3 9 18 30 45 63 84 108
B18 30 45 63 84 108正確答案
C0 0 3 9
D沒有任何輸出
答案與詳解
B
正確答案
陣列 a[i+1]=a[i]+i*3,i=0~9;a[i]<10 時 continue 不印,≥10 才印。

為什麼答案是 B

正確。a[i]<10 時 continue 跳過 printf,所以 a[0]=0,a[1]=0,a[2]=3,a[3]=9 不印;a[4]=18 起皆 ≥10 全部印出:18 30 45 63 84 108。

考點:忽略continue考點:continue過濾考點:continue vs break考點:誤判條件
載入中…

計算機概要 相關題目

想練更多計算機概要考古題?

Examly 收錄 38 萬+ 道歷屆題目,每題都有像這樣的精選詳解。免費下載,立即開練。

Download on theApp Store即將推出Google Play
黑皮