#include <iostream> using namespace std; int count(int n){ if(n < 3){ return 1; }else{ return count(n-1) + count(n - 2); } } int main(){ int n; if(cin>>n){ // 第三个月起,每个月都会生出一只兔子,生出来的兔子同理 cout<<count(n)<<endl; } }
#include <iostream> using namespace std; int count(int n){ if(n < 3){ return 1; }else{ return count(n-1) + count(n - 2); } } int main(){ int n; if(cin>>n){ // 第三个月起,每个月都会生出一只兔子,生出来的兔子同理 cout<<count(n)<<endl; } }