递归和非递归分别实现求第n个斐波那契数 例如: 输入:5 输出:5 输入:10, 输出:55 输入:2, 输出:1 #include<stdio.h> int main() { int n; int c = 2; int a = 1; int b = 1; scanf("%d", &n); for (int i = 0; i < n-1; i++) { a = b; b = c; c = a + b; } printf("%d", a); }//非递归 #include<stdio.h> int Fib(int n) { if (n == 1 || n == 2) return 1; return Fib(n - 1) + Fib(n - 2); } int main() { int n; scanf("%d", &n); int ret = Fib(n); printf("%d", ret); }