标签:io for on sp c print include bs
/*
假设一对耗子每个月都可以生一对小耗子。小耗子生长3个月后,从第4个月开始也就能够生小耗子。
问:假设所有的耗子都不死的话,那么20个月后一共有多少只耗子?
*/
#include <stdio.h>
void main()
{
int old = 2,first = 0,second = 0,third = 0;
int i= 0;
for(;i < 20;i++)
{
old = old + third;
third = second;
second = first;
first = old;
}
printf("第20个月一共有%d只耗子!\n",old + first + second + third);
}
假设一对耗子每个月都可以生一对小耗子... ...,布布扣,bubuko.com
标签:io for on sp c print include bs
原文地址:http://www.cnblogs.com/wenhuan/p/3918948.html