题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
http://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
递归
#include <vector>
#include <iostream>
using namespace std;
int helper(int n) {
if (n < 3) return 1;
return helper(n-1) + helper(n-2);
}
int main() {
int n = 0;
while (cin >> n) {
int res = helper(n);
cout << res << endl;
}
return 0;
}