U E D R , A S I H C RSS

새싹교실/2017/따라와반/과제방/자바/1회차

No difference found



오늘의 실습 내용

이민욱

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        long[] FIBO = new long[100];

        int i;
        for(i=0;i<100;i++){
            FIBO[i]=-1;
        }
        FIBO[0]=0;
        FIBO[1]=1;
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        for(i=2;i<=N;i++){
            if(FIBO[i]==-1){
                FIBO[i]=FIBO[i-2]+FIBO[i-1];
            }
        }
        System.out.printf("%d",FIBO[N]);
    }
}

정석우

import java.util.Scanner;

public class Hello 
{
	public static void main(String[] args)
	{
		long arr[] = new long [100];
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		arr[0] = 0;
		arr[1] = 1;
		for(int i=2; i<=n; i++)
		{
			arr[i] = arr[i-2] + arr[i-1];
		}
		System.out.println(arr[n]);
	}
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:08
Processing time 0.0476 sec