#include <stdio.h> int fib(int n); void PrintFN(int m, int n); int main() { int m, n, t; scanf("%d %d %d", &m, &n, &t); printf("fib(%d) = %d\n", t, fib(t)); PrintFN(m, n); system("pause"); return 0; } /* 你的代码将被嵌在这里 */ int fib(int n) { if (n == 1 || n == 2) return 1; else return fib(n - 1) + fib(n - 2); } void PrintFN(int m, int n) { int i = 1; int flag = 1;//最后一个数后没有空格 int count = 0;//判断是否有 Fibonacci数在区间内 while (fib(i) < m) { i++; } while (fib(i) <= n) { if (flag) { printf("%d", fib(i)); flag = 0; } else { printf(" %d", fib(i)); } count++; i++; } if (count == 0) { printf("No Fibonacci number\n"); } }