标签:sys str ati ring pac ted ack 长大 com
开始有两只老鼠,每个月繁殖一对幼鼠,幼鼠三个月长大,即可繁殖,
问二十四个月后共有多少只老鼠(不考虑老鼠死亡、雌雄问题)?
package com.lovo.homework;
public class TestMouse {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int old = 2,first = 0, second = 0, third = 0;
for(int i = 0; i < 24; i++){
old = old + third;
third = second;
second = first;
first = old;
}
System.out.println(old + first + second + third);
}
}
标签:sys str ati ring pac ted ack 长大 com
原文地址:http://www.cnblogs.com/fengshaolingyun/p/6785135.html