long Fibonacci(n)
{
if (n > 2)
return Fibonacci(n-1)+Fibonacci(n-2);
else
return 1;
}
#include<stdio.h>
int main()
{
int f1,f2;
int month,ct;
printf("请输入月份:");
scanf("%d",&month);
if(month<=2)
printf("两只。\n");
if (month > 2)
{
f1 = f2 = 1;
ct = 0;
while(ct < month -2){
f1 = f1+f2;
ct += 1;
f2 = f1+f2;
ct += 1;
}
if (month %2 == 0){
printf("第 %d 个月的兔子对数为:%d.\n",month,f2);
}
if (month %2 == 1){
printf("第 %d 个月的兔子对数为:%d.\n",month,f1);
}
}
return 0;
}
#include<stdio.h>
long Fibonacci(n)
{
if (n > 2)
return Fibonacci(n-1)+Fibonacci(n-2);
else
return 1;
}
int main()
{
long num;
int month;
printf("请输入月份:");
scanf("%d",&month);
num = Fibonacci(month);
printf("这个月的兔子对数为%d.\n",num);
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有