| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1218 人关注过本帖
标题:[求助]经典兔子问题
只看楼主 加入收藏
ajey2004
Rank: 1
等 级:新手上路
帖 子:164
专家分:0
注 册:2004-12-30
收藏
 问题点数:0 回复次数:7 
[求助]经典兔子问题
古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月
   后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?
那位好心人帮俺写上,俺想了好几天没想出来
搜索更多相关主题的帖子: 兔子 经典 
2005-06-15 11:24
无心
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2005-3-15
收藏
得分:0 
去网上搜"经典程序百例"

因为把心给了你,所以我无心.
2005-06-15 14:45
seeker
Rank: 1
等 级:新手上路
帖 子:172
专家分:0
注 册:2005-6-5
收藏
得分:0 
#include "stdio.h"
#include "conio.h"
main()
{
  long f1,f2;
  int i;
  f1=f2=1;
  for(i=1;i<=20;i++)
  {
    printf("%12ld %12ld",f1,f2);
    if(i%2==0) printf("\n"); /*控制输出,每行四个*/
    f1=f1+f2; /*前两个月加起来赋值给第三个月*/
    f2=f1+f2; /*前两个月加起来赋值给第三个月*/
  }
  getch();
}

我相信总有一片天空属于我!http://myseeker. E-Mail:lwqcny@
2005-06-16 00:10
zefil415
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2005-6-4
收藏
得分:0 
上面好像没有体现"出生后第三个月起"的意思啊???
2005-06-16 01:49
指向指针的指针
Rank: 1
等 级:新手上路
帖 子:339
专家分:0
注 册:2004-8-8
收藏
得分:0 

#include<iostream.h> void main(){ int months,i; long int firstmonth=1,secondmonth=0,adult=0; cin>>months; for(i=1;i<=months;i++){ cout<<"the "<<i<<"month ,the number of rubbit is"<<adult<<endl;

adult=adult+secondmonth; secondmonth=firstmonth; firstmonth=adult; cout<<"the total is "<<adult<<endl; }; }

不知行不?


/sign.png" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www./sign.png');}" onmousewheel="return imgzoom(this);" alt="" />
2005-06-17 19:17
ajey2004
Rank: 1
等 级:新手上路
帖 子:164
专家分:0
注 册:2004-12-30
收藏
得分:0 
呵呵我做出来了,还做了张图
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;graphics.h&gt;

void main(void)
{
    int sum,r1=1,r2=0,r3=0;
    int i,j,k;
    int n;
    int g=VGA,mode=VGAHI;
int x,y;
    int x0,y0;
    int *p;
    clrscr();
    printf("input the n:");
    scanf("%d",&amp;n);
    p=(int *)malloc(n*sizeof(int));
    if (p==NULL)
    {
        printf("\nwrong!\n");
        exit(0);
    }
    printf("input the 3p:");
    scanf("%f%f%f",&amp;p1,&amp;p2,&amp;p3);
    initgraph(&amp;g,&amp;mode,"");
    setbkcolor(WHITE);
    setcolor(BLUE);
    line(150,380+5,150,50);
    line(150,380,500,380);
    moveto(150,50);
    linerel(-3,6);
    moveto(150,50);
    linerel(3,6);
    moveto(500,380);
    linerel(-6,-3);
    moveto(500,380);
    linerel(-6,3);
    for (j=0;j&lt;=300;j+=25)
    {
        line(145,380-j,150,380-j);
    }
    for (k=0;k&lt;=300;k+=25)
    {
        line(k+150,380,k+150,377);
    }
    for (i=2;i&lt;=n;i++)
    {
        r3=r3+;
        r2=r1;
        r1=r3;
        sum=r1+r2+r3;
        x0=i*10;
        y0=sum/2;
        x=x0+150;
        y=480-1*y0-100;
        *(p+(i-2)*2)=x;
        *(p+(i-2)*2+1)=y;
    }
    drawpoly(n,p);
    getchar();
    getchar();
    getchar();
    closegraph();
free(p);
}

2005-06-18 10:46
城门口
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-4-8
收藏
得分:0 
main()
{
 int i, ny,sum,n=3;
 printf("please input the number of \'ny\':");
 scanf("%d",&amp;ny);
 if(ny&gt;=3)
 {
  sum=ny-3+2;
  for(;n&lt;ny;n++)
  {
   i=1;
   while((ny-n)&gt;=3*i)
   {
    sum+=ny-n-3*i+1;
    i++;
   }
  }
}
 else sum=1;
 printf("%d\n",sum);
}
2005-06-18 22:42
改变自己
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-6
收藏
得分:0 

老谭那书里有这题啊

2006-01-09 01:55
快速回复:[求助]经典兔子问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022763 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved