Advertisement
Flaron

ProgMasters 11 - Find three

Jun 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7. int n=scanner.nextInt();
  8. int[] array=new int[n];
  9. int k =0;
  10. while (k<n) {
  11. int b=scanner.nextInt();
  12. array[k]=b;
  13. k++;
  14. }
  15. boolean vanE=false;
  16. final int keresett=3;
  17. int j=0;
  18.  
  19. for (int i = 0; i < array.length; i++) {
  20. if (array[i]==keresett) {
  21. j++;
  22. }
  23. }
  24.  
  25. if (j==keresett) {
  26. for (int i = 0; i < n-1; i++) {
  27. if (array[i]==3 && array[i+1]==3) {
  28. vanE=true;
  29. }
  30. //else vanE=false;
  31.  
  32. }
  33.  
  34. System.out.println(vanE==false? "false":"true");
  35. }
  36. else System.out.println("true");
  37.  
  38. scanner.close();
  39.  
  40.  
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement