选择题
编程题
题目1
import java.util.Scanner;public class Main { public static void main(String[] args) {//1 |1 //1 |1//1 1 |2//1 1 1 |3//1 1 1 1 1 |5Scanner sc = new Scanner(System.in);int n = sc.nextInt();//从出生后第3个月起每个月都生一只兔子//一月的时候有一只兔子if(n == 1 || n == 2) {System.out.println(1);return ;}int f1 = 1;int f2 = 1;for(int i=3;i<=n;i++) {int f3 = f1 + f2;f1 = f2;f2 = f3;}System.out.println(f2);sc.close();}
}