將費氏數列輸出至一long 陣列
其中f[0]=1, f[1]=2, f[n]=f[n-1]+f[n-2] (n>=2)
herrDeng網內搜尋
自訂搜尋
Ads
2011年10月6日 星期四
訂閱:
張貼留言 (Atom)
熱門文章
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
python pandas對黃金、外匯匯率的爬蟲練習,並使用matplotlib.pyplot的函數plot, scatter做資料視覺化處理,採用numpy的統計函數,分析黃金價格波動與歐元走勢的關聯。
-
Python C C++ 2 pointer速解Leetcode 2337 Move Pieces to Obtain a String 多日Leetcode的問題都可用2-pointer法來解,今日2337. Move Pieces to Obtain a String也不例...
-
你會用C的算子sizeof?
68 則留言:
public class A {
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package p1;
public class a1 {
public static void main(String[] args) {
{
long[] f = new long[100] ;
f[0] = 1; f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();} }
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package B9933057;
public class B9933057 {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package P1;
public class A1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
public class B1 {
public static void main(String[] args) {
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length;i++)
{
f[i]=(f[i-1]+f[i-2]);
System.out.println("f["+i+"]="+f[i]);
}
}
}
public class b9933014 {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i=2;i<f.length;i++)
{
f[i] = f[i-1] + f[i-2];
}
for(int i=0;i<f.length;i++)
{
System.out.print(" "+f[i]);
System.out.println();
}
}
}
package A2;
public class A1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{
f[i] = f[i-1] + f[i-2];
}
for(int i = 0; i < f.length; i++)
{
System.out.print(" "+f[i]);
System.out.println();
}
}
}
package P1;
public class B9933052A {
public static void main(String[] args) {
long [] f =new long[100];
f[0]=1;
f[1]=2;
for (int i=2;i<f.length;i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]="+f[i]);
}
}
}
最大陣列值到f[90];
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
public class B1 {
public static void main(String[] args) {
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length;i++)
{
f[i]=(f[i-1]+f[i-2]);
System.out.println("f["+i+"]="+f[i]);
}
}
}
最大陣列值到f[90]
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package A2;
public class A1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{
f[i] = f[i-1] + f[i-2];
}
for(int i = 0; i < f.length; i++)
{
System.out.print(" "+f[i]);
System.out.println();
}
}
}
package b9933024;
public class a1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package p1;
public class a {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();} }
}
package B9933040;public class B9933040 { public static void main(String[] args) { long[] f = new long[100] ; f[0] = 1; f[1] = 2; for(int i = 2; i < f.length; i++) {f[i] = f[i-1] + f[i-2];} for(int i = 0; i < f.length; i++) {System.out.print(" "+f[i]); System.out.println();} } }
package pack1;
import java.io.*;
public class A1 {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
package B9933004;public class B9933004 { public static void main(String[] args) { long[] f = new long[100] ; f[0] = 1; f[1] = 2; for(int i = 2; i < f.length; i++) {f[i] = f[i-1] + f[i-2];} for(int i = 0; i < f.length; i++) {System.out.print(" "+f[i]); System.out.println();} } }
package pack1;
import java.io.*;
public class test1 {
public static void main(String[] args) {
long [] fib =new long[100];
fib[0]=1;
fib[1]=2;
for(int i=2;
i<fib.length;i++)
fib[i]=fib[i-1]+fib[i-2];
for(int i=0;
i<fib.length;i++)
System.out.println(i+"->"+fib[i]+" " );
System.out.println();
}
}
package B9933046;public class B9933046 { public static void main(String[] args) { long[] f = new long[100] ; f[0] = 1; f[1] = 2; for(int i = 2; i < f.length; i++) {f[i] = f[i-1] + f[i-2];} for(int i = 0; i < f.length; i++) {System.out.print(" "+f[i]); System.out.println();} } }
package pack1;
import java.io.*;
public class test1 {
public static void main(String[] args) {
long [] fib =new long[100];
fib[0]=1;
fib[1]=2;
for(int i=2;
i<fib.length;i++)
fib[i]=fib[i-1]+fib[i-2];
for(int i=0;
i<fib.length;i++)
System.out.println(i+"->"+fib[i]+" " );
System.out.println();
}
}
public class b9933011 {
public static void main(String[] args) {
long []f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2;i<f.length;i++)
{
f[i]=(f[i-1]+f[i-2]);
System.out.println("f["+i+"]="+f[i]);
}
}
}
最大陣列數值 90
public class B41 {
public static void main(String[] args) {
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2;i<f.length;i++)
{
f[i]=(f[i-1]+f[i-2]);
System.out.println("f["+i+"]="+f[i]);
}
}
}
最大陣列數值是90
package p1;
public class b1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length; i++)
f[i]= f[i-1]+f[i-2];
for(int i=0; i<f.length; i++)
System.out.println(i+"->"+f[i]+" ");
System.out.println();
}
}
最大索引值=90
public static void main(String[] args)
{
long[] f = new long[100];
f[0] = 0;
f[1] = 1;
for(int i = 2; i < f.length; i++)
f[i] = f[i-1] + f[i-2];
for(long number : f)
System.out.print(number + " ");
System.out.println();
}
package pack1;
public class A1 {
public static void main(String[] args) {
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length;i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]="+f[i]);
}
}
}
最大值f[90];
long [] f=new long[100];
f[0]=1;
f[1]=2;
for(int i = 2; i <f.length; i++)
f[i] = f[i-1] + f[i-2];
for(int i = 0; i < f.length; i++)
System.out.print(f[i] + " ");
System.out.println();
package pack;
public class pack {
public static void main(String[] args) {
long [] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length; i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]="+f[i]);
}
}
}
最大值f[90];
package pack1;
import java.io.*;
public class test1 {
public static void main(String[] args) {
long [] fib =new long[100];
fib[0]=1;
fib[1]=2;
for(int i=2;
i<fib.length;i++)
fib[i]=fib[i-1]+fib[i-2];
for(int i=0;
i<fib.length;i++)
System.out.println(i+"->"+fib[i]+" " );
System.out.println();
}
}
最大索引值=90
package pack1;
public class B1 {
public static void main(String[] args) {
long[] fib =new long[100];
fib[0] = 1;
fib[1] = 2;
for(int i = 2;
i < fib.length; i++)
fib[i] = fib[i-1] + fib[i-2];
for(int i = 0;
i < fib.length; i++)
System.out.println(i+"->"+fib[i] + " ");
System.out.println();
}
}
最大索引直:90
package pack1;
public class A1 {
public static void main(String[] args) {
long[] fib=new long[100];
fib[0]=1;
fib[1]=2;
for(int i=2;
i <fib.length;i++)
fib[i]=fib[i-1]+fib[i-2];
for(int i=0;
i <fib.length;i++)
System.out.println(i+"->"+fib[i]+" ");
System.out.println();
}
}
最大索引值=90
package p1;
public class p1 {
public static void main(String[] args) {
long []fib=new long [91];
fib[0]=1;
fib[1]=2;
for(int i=2; i<fib.length; i++ )
fib[i]=fib[i-1]+fib[i-2];
for(int i=0; i<fib.length; i++ )
System.out.println(i+"->"+fib[i]+" ");
System.out.println();
}
}
最大索引值:90
package p1;
public class b2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
long []fib=new long [91];
fib[0]=1;
fib[1]=2;
for(int i=2; i<fib.length; i++)
fib[i]=fib[i-1]+fib[i-2];
for(int i=0; i<fib.length; i++)
System.out.println(i+"->"+fib[i]+" ");
System.out.println();
}
}
最大索引值90
package a1;
public class a1 {
public static void main(String[] args) {
long[]f=new long[100];
f[0]=1;
f[1]=2;
for(int i = 2; i < f.length; i++)
f[i] = f[i-1] + f[i-2];
for(int i = 0; i < f.length; i++)
System.out.println("f"+i+"="+" "+f[i]);
System.out.println();
}
}
答案最大是F90
package p4;
public class M1 {
public static void main(String[] args) {
long f[]=new long[100];
f[0]=1;
f[1]=2;
for ( int i=2;i<f.length;i++)
f[i]=f[i-1]+f[i-2];
for (int i=0;i<f.length;i++)
System.out.println(i+"->"+f[i]+" ");
System.out.println();
}
}
package p1;
public class B1 {
public static void main(String []args){
long f[]=new long [100];
f[0]=1;
f[1]=2;
for ( int i=2;i<f.length;i++)
f[i]=f[i-1]+f[i-2];
for (int i=0;i<f.length;i++)
System.out.println(i+"->"+f[i]+" ");
System.out.println();
}
}
public class P1 {
public static void main(String[] args) {
long[]f=new long [100];
f[0]=1;
f[1]=2;
for(int i=2;i<f.length;i++)
f[i]=f[i-1]+f[i-2];
for(int i=0; i<f.length;i++)
System.out.println(i+" "+f[i]+" ");
System.out.println();
}
}
最大值:90
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print("f"+i+" "+f[i]);
System.out.println();}
}
}
最大值在90
package pack;
public class pack {
public static void main(String[]args) {
long [] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length; i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]="+f[i]);
}
}
}
package p1;
public class p1 {
public static void main(String[] args) {
long []fib=new long [91];
fib[0]=1;
fib[1]=2;
for(int i=2; i<fib.length; i++ )
fib[i]=fib[i-1]+fib[i-2];
for(int i=0; i<fib.length; i++ )
System.out.println(i+"->"+fib[i]+" ");
System.out.println();
}
}
最大索引值:90
最大值=90
package C1;
public class C1 {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print("f"+i+" "+f[i]);
System.out.println();}
}
}
90為最大值
package C1;
public class C1 {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print("f"+i+" "+f[i]);
System.out.println();}
}
}
package p1;
public class a {
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();} }
}
最大索引值=90
最大值=90
package p1;
public class B1 {
public static void main(String []args){
long f[]=new long [100];
f[0]=1;
f[1]=2;
for ( int i=2;i<f.length;i++)
f[i]=f[i-1]+f[i-2];
for (int i=0;i<f.length;i++)
System.out.println(i+"->"+f[i]+" ");
System.out.println();
}
}
public class B1
{
public static void main(String[] args)
{
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i = 2; i < f.length; i++)
f[i] = f[i-1] + f[i-2];
for(int i = 0; i < f.length; i++)
System.out.println("f"+i+"="+" "+f[i]);
System.out.println();
最大值是 f90
public class b9733054 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i;
long f[]=new long[100];
f[0]=1;
f[1]=2;
for(i=2;i<f.length;i++){
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]="+f[i]);
}
}
}
/*索引最大值到90*/
package gan;
class gan{
public static void main(String[]args){
long[] f = new long[100];
f[0]=1;
f[1]=2;
for(int i = 2; i <f.length;i++) {
f[i] = f[i-1] + f[i-2];
}
for(int i = 0; i < f.length;i++) {
System.out.print("f"+i+ " "+f[i]);
System.out.println();
}
}
}
public class abcd {
public static void main(String[] args) {
long [] f=new long[100];
f[0]=1;
f[1]=2;
for (int i=2;i<f.length;i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]"+f[i]);
}
}
}
*****第90個開始出錯*****
public class abc {
public static void main(String[] args)
{
long [] f=new long[100];
f[0]=1;
f[1]=2;
for(int i=2;i<f.length;i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("["+i+"]"+f[i]);
}
}
}
###到90行以前都是正確的,91行開始出錯出現負號###
package C1;
public class C2 {
public static void main(String[] args) {
⋯⋯
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print("f"+i+" "+f[i]);
System.out.println();}
}
}
package B9;
public class b9933016
{
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print("f"+i+" "+f[i]);
System.out.println();}
}
}
99
package B9;
public class b9933016
{
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print("f"+i+" "+f[i]);
System.out.println();}
}
}
89
package B9;
public class b9933016
{
public static void main(String[] args) {
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
public class Fibonacci
{
public static void main(String[] args)
{
int n=100;
long f[]=new long[n];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length;i++){
f[i]=f[i-1]+f[i-2];
if (f[i]<=f[i-1])
{break;}
System.out.println("f["+i+"]="+f[i]);
}
}
}
public class Fibonacci {
public static void main(String[] args) {
int n=100;
long f[]=new long[n];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length;i++){
f[i]=f[i-1]+f[i-2];
if (f[i]<=f[i-1])
{break;}
System.out.println("f["+i+"]="+f[i]);
}
}
}
public class d1 {
public static void main(String[] args) {
int n=100;
long f[]=new long[n];
f[0]=1;
f[1]=2;
for(int i=2; i<f.length;i++){
f[i]=f[i-1]+f[i-2];
if (f[i]<=f[i-1])
{break;}
System.out.println("f["+i+"]="+f[i]);
}
}
}
public class abcd {
public static void main(String[] args) {
long [] f=new long[100];
f[0]=1;
f[1]=2;
for (int i=2;i<f.length;i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]"+f[i]);
}
}
}
public class abcd {
public static void main(String[] args) {
long [] f=new long[100];
f[0]=1;
f[1]=2;
for (int i=2;i<f.length;i++)
{
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]"+f[i]);
}
}
}
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
public class A1
{
public static void main(String[] args)
{
long[] f=new long[100];
f[0]=1;
f[1]=2;
for(int i = 2; i < f.length; i++)
f[i] = f[i-1] + f[i-2];
for(int i = 0; i < f.length; i++)
System.out.println("f"+i+"="+" "+f[i]);
System.out.println();
最大值是 f90
package P1;
public class A1
{
public static void main(String[] args)
{
long[] f = new long[100] ;
f[0] = 1;
f[1] = 2;
for(int i = 2; i < f.length; i++)
{f[i] = f[i-1] + f[i-2];}
for(int i = 0; i < f.length; i++)
{System.out.print(" "+f[i]);
System.out.println();}
}
}
張貼留言