int fb(int m) { int r = 1, s = 1, t; if (m >= 1) printf("%d ", r); if (m >= 2) printf("%d ", s); if (m >= 3) { m -= 2;//已經計算出2個了 while (m-- >= 1) { t = s; s += r; r = t; printf("%d ", s); } } }
main() { int n; scanf("%d", &n); fb(n); getch(); } 測試正確,請采納