题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner fzhinput = new Scanner(System.in);
int monthnum = fzhinput.nextInt();
int rnum[]=new int[monthnum+1];
for(int month=0;month<=monthnum;month++){
if(month<=2){
rnum[month] = 1;
}
else if(month>=3){
rnum[month]= rnum[month-1]+rnum[month-2];
}
}
System.out.println(rnum[monthnum]);
}
}
// {1,1,2,3,5,8,13,21,34,55}