有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月 后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?输出至少24个月的
有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?输出至少24个月的
2011-09-24 22:33
2011-09-26 22:00
2011-09-26 22:46
程序代码: class tu
{
static void Main()
{
int[] tu = new int[24];
tu[0] = 1;
tu[1] = 1;
for(int i = 2; i < tu.Length; i++)
{
tu[i] = tu[i - 2] + tu[i - 1];
Console.WriteLine("{0}月的兔子有:{1}", i+1 , tu[i]);
}
}
}
2011-12-08 23:42