语言用递归法解兔子繁殖问题(斐波那契数列),求每月的兔子数目.#include void main(){int f(int n);int mounth,mounth_num;printf("请输入月份:");scanf("%d",&mounth);mounth_num=f(mounth);printf("当月兔子的数目为");pr
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 08:59:24
语言用递归法解兔子繁殖问题(斐波那契数列),求每月的兔子数目.#include void main(){int f(int n);int mounth,mounth_num;printf("请输入月份:");scanf("%d",&mounth);mounth_num=f(mounth);printf("当月兔子的数目为");pr
语言用递归法解兔子繁殖问题(斐波那契数列),求每月的兔子数目.
#include
void main()
{
int f(int n);
int mounth,mounth_num;
printf("请输入月份:");
scanf("%d",&mounth);
mounth_num=f(mounth);
printf("当月兔子的数目为");
printf("%d\n",mounth_num);
}
int f(int n)
{
int m=0;
if (n=1||n=2)
\x05 return 1;
else
{\x05 m=f(n-1)+f(n-2);
return m;
}
}
系统提示F:\vc++6.0\MSDev98\MyProjects\兔子问题\兔子问题.cpp(16) :error C2106:'=' :left operand must be l-value
语言用递归法解兔子繁殖问题(斐波那契数列),求每月的兔子数目.#include void main(){int f(int n);int mounth,mounth_num;printf("请输入月份:");scanf("%d",&mounth);mounth_num=f(mounth);printf("当月兔子的数目为");pr
if (n=1||n=2)
改成
if (n==1||n==2)