#include<stdio.h>
void main()
{
int i;
int a[100];
int month;
printf("输入月数:");
scanf_s("%d", &month);
a[0] = 1;
a[1] = 1;
a[2] = 2;
for (i = 3; i < month; i++)
{
a[i] = a[i - 1] + a[i - 2];
}
for (i = 0; i < month; i++)
{
printf("第%d月是%d只\n", i + 1, a[i]);
}
getchar();
getchar();
}
运行结果