/*
Name: C语言经典算法100例011
Copyright: *
Author: 巧若拙
Date: 25-08-14 23:03
Description:
题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月
后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?
程序分析:斐波那契数列
*/
#include<stdio.h>
#include<stdlib.h>
void fun1(void);
int main(void)
{
fun1();
system("pause");
return 0;
}
void fun1(void)
{
int mon, i;
int n1, n2, n3;
n1 = n2 = 1;
puts("请输入查询月份:");
scanf("%d", &mon);
for (i=2; i<mon; i++)
{
n3 = n1 + n2;
n1 = n2;
n2 = n3;
}
printf("%d月的兔子数量为%d\n", mon, n2);
}
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------