//有一对兔子出生后第三个月起每个月都生一对兔子,加入兔子不死问每个月兔子的总数为多少? #include<iostream> using namespace std; int main() { int sum[20],chusheng[20]; sum[0] = 2; chusheng[0] = 0; for (int i = 0; i < 20; i++) { if (i < 2) { sum[i] = sum[0]; chusheng[i] = chusheng[0]; } else { chusheng[i] = sum[i - 2]; sum[i] = sum[i - 1]+chusheng[i]; } cout << "第" << i + 1 << "个月总共有" << sum[i]/2 << "对兔子" << endl; } return 0; }