執行下列 C 程式後,產生的輸出為何? #include<stdio.h> int main() { int a = 50; int b = 1; while (a!= b) { if (a%b == 0) { printf("%d", b); } b++; } return 0; }
A1 10 20 30 40 50
B1 5 10 15 20 25 30 35 40 45 50
C1 2 5 10 25正確答案
D1 2 5 10
答案與詳解
b 從 1 遞增,當 50%b==0 時印出 b。50 的真因數(不含自己):1、2、5、10、25。b=50 時 while 條件 a!=b 不成立而跳出,故不印 50。
