开始有两只老鼠,每个月繁殖一对幼鼠,幼鼠三个月长大,即可繁殖,
问二十四个月后共有多少只老鼠(不考虑老鼠死亡、雌雄问题)?
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);
}

}

相关文章:

  • 2021-12-14
  • 2022-01-26
  • 2022-12-23
  • 2022-02-11
  • 2022-02-06
  • 2021-11-18
  • 2022-02-04
  • 2021-11-29
猜你喜欢
  • 2021-05-20
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案