欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

用java編寫程序輸出Fibonacci序列

錢浩然2年前21瀏覽0評論

用java編寫程序輸出Fibonacci序列?

用java寫用遞歸算法計算,并輸出Fibonacci數列的前20項。

public class Fib_array {,public static void main(String[] args) {, int fib[] = new int[20];int i, n = 20;fib[0] = 0;fib[1] = 1 for (i = 2; i < fib.length; i++) fib[i] = fib[i - 1]+ fib[i - 2];for (i = 0; i < 5; i++)System.out.print(" " + fib[i]);System.out.println();for (i = 5; i < 10; i++)System.out.print(" " + fib[i]); System.out.println(); for (i = 10; i < 15; i++)System.out.print(" " + fib[i]);.out.println(); for (i = 15; i < 20; i++)System.out.print(" " + fib[i]);System.out.println();

java序列,用java編寫程序輸出Fibonacci序列