急求一个c语言程序 有题目 有50行左右

最好用到if语句... 最好用到if语句 展开
 我来答
3647743
2008-03-17 · TA获得超过568个赞
知道答主
回答量:199
采纳率:0%
帮助的人:167万
展开全部
从前有一对兔子,它们每一个月生一对兔子,新生的小兔子
两个月就张大了,在第二个月的月底开始生它们的下一代小兔子,这样一代一代生下去,求解兔子的增长数量的数列。

#include<stdio.h>
void main()
{
int n,i,j,un1,un2,un;
clrscr();
puts("********************************************************");
puts("* This is a program to Calculate Rabbits Numbers. *");
puts("* There is a rabbit couple procreats 2 rabbits 1 month,*");
puts("* and the young rabbits group and can procreats in the *");
puts("* end of the second month. In this way,how many rabbits*");
puts("* are there after n generations? *");
puts("********************************************************");
for(n=2;n<3;)
{
printf(" >> Please input number of generations (n>2): ");
scanf("%d",&n);
if(n<3) printf("\n >> Input error!\n"); /*控制输入正确的N值*/
}
un=un2=1;
printf(" >> The numbers of rabbits in first %d generation are as follows:\n",n);
printf(" l\t l\t");

for(i=3,j=0;i<=n;i++)
{
un1=un2;
un2=un;
un=un1+un2; /*利用通项公式求解N项的值*/
printf( i%8?" %d\t":"%d\n",un);
}
printf("\n");
printf("\n Press any key to quit...");
getch();
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式