#include<stdio.h> int count(int n) { if (n==1||n==2) return 1; else return count(n-1)+count(n-2);//本质上是斐波那锲数列,用递归来计算 }//f(n)=f(n-1)+f(n-2) int main() { int num,res; while(scanf("%d",&num)!=EOF) { res=count(num); printf("%d\n",res); } }
#include<stdio.h> int count(int n) { if (n==1||n==2) return 1; else return count(n-1)+count(n-2);//本质上是斐波那锲数列,用递归来计算 }//f(n)=f(n-1)+f(n-2) int main() { int num,res; while(scanf("%d",&num)!=EOF) { res=count(num); printf("%d\n",res); } }