Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.* ;
- class Ppa1_cv06_1_A14B0537P {
- public static void main(String[]args)
- {
- Scanner sc = new Scanner(System.in);
- int pocetClenu = sc.nextInt() ;
- int a0 = 0 ;
- int a1 = 1 ;
- int a2 = 1 ;
- System.out.println("---Vysledky---") ;
- if (pocetClenu == 0)
- {
- System.out.println("[0]") ;
- }
- else if (pocetClenu == 1)
- {
- System.out.println("[0, 1]") ;
- }
- else if (pocetClenu == 2)
- {
- System.out.println("[0, 1, 1]") ;
- }
- else
- {
- int [] pole = {0 , 1 , 1};
- for (int i= 3; i <= pocetClenu; i++, pole = dalsiClen(pole))
- System.out.println(Arrays.toString(pole));
- }
- }
- static int[] dalsiClen(int[] pole)
- {
- int [] temp = new int[pole.length +1];
- for (int j = 0 ; j < pole.length ; j++ )
- {
- temp[j] = pole[j];
- }
- temp[pole.length -1 ] = temp[temp.length -3] + temp[temp.length -2] ;
- return temp ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement