Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public class Main {
  2.  
  3.  
  4. public static int rozwiazanie(int[] A)
  5. {
  6. boolean x=false;
  7. int wynik=1;
  8. int pomocnicza=10000000;
  9.  
  10. for(int i=0;i<A.length;i++)
  11. {
  12. if (A[i]>0)
  13. {
  14. boolean nie_brakuje = false;
  15. int brakujaca;
  16. for (int j = 0; j < A.length; j++) {
  17. if (A[i] + 1 == A[j]) nie_brakuje = true;
  18. }
  19. if (nie_brakuje == false) {
  20. brakujaca = A[i] + 1;
  21. if (brakujaca < pomocnicza)
  22. {
  23. wynik = brakujaca;
  24. pomocnicza=brakujaca;
  25. }
  26. }
  27. }
  28.  
  29. }
  30.  
  31. return wynik;
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38. public static void main(String[] args)
  39. {
  40. int[] a= new int[5];
  41. a[0]=3;
  42. a[1]=5;
  43. a[2]=6;
  44. a[3]=7;
  45. a[4]=9;
  46. System.out.println(rozwiazanie(a));;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement