日期:2014-05-20 浏览次数:20689 次
public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] fb = new int[10000]; fb[0] = 1; fb[1] = 1; for(int i = 0; i < n; i++){ fb[i + 2] = fb[i] + fb[i + 1]; } System.out.println(fb[n - 1]); } //---------------------------------------------------- public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); System.out.println(fb(n - 1)); } public static int fb(int n){ if(n == 1 || n == 0){ return 1; }else{ return fb(n - 1) + fb(n - 2); } }