统计每个月兔子总数
统计每个月兔子的总数
http://www.nowcoder.com/questionTerminal/1221ec77125d4370833fd3ad5ba72395
include
using namespace std;
//第month月的兔子数:由上个月生的兔子数count_num(month-1)
// 和满足3个月大的兔子生的兔子数 count_num(month-2)
int count_num(int month)
{
if(month==1 || month==2)
return 1;
return count_num(month-1)+count_num(month-2);
}
int main()
{
int month;
int ret;
while(cin>>month)
{
cout<<count_num(month)<<endl;
}
return 0;
}