Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import java.util.* ;
  2. class Ppa1_cv06_1_A14B0537P {
  3. public static void main(String[]args)
  4. {
  5. Scanner sc = new Scanner(System.in);
  6. int pocetClenu = sc.nextInt() ;
  7. int a0 = 0 ;
  8. int a1 = 1 ;
  9. int a2 = 1 ;
  10. System.out.println("---Vysledky---") ;
  11. if (pocetClenu == 0)
  12. {
  13. System.out.println("[0]") ;
  14. }
  15. else if (pocetClenu == 1)
  16. {
  17. System.out.println("[0, 1]") ;
  18. }
  19. else if (pocetClenu == 2)
  20. {
  21. System.out.println("[0, 1, 1]") ;
  22. }
  23. else
  24. {
  25. int [] pole = {0 , 1 , 1};
  26.  
  27.  
  28. for (int i= 3; i <= pocetClenu; i++, pole = dalsiClen(pole))
  29. System.out.println(Arrays.toString(pole));
  30. }
  31. }
  32. static int[] dalsiClen(int[] pole)
  33. {
  34. int [] temp = new int[pole.length +1];
  35. for (int j = 0 ; j < pole.length ; j++ )
  36. {
  37. temp[j] = pole[j];
  38.  
  39. }
  40. temp[pole.length -1 ] = temp[temp.length -3] + temp[temp.length -2] ;
  41.  
  42. return temp ;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement