daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class АrrayP07 {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int[] array = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
  9.  
  10.         int arr = array[0];
  11.         int maxCounter = 0;
  12.         for (int i = 0; i < array.length; i++) {
  13.             int counter = 0;
  14.             for (int j = i + 1; j < array.length ; j++) {
  15.  
  16.                 if (array[i] == array[j]) {
  17.                     counter++;
  18.                     if (counter > maxCounter) {
  19.                         maxCounter = counter;
  20.                         arr = array[i];
  21.  
  22.                     }
  23.                 } else {
  24.                     break;
  25.                 }
  26.             }
  27.  
  28.         }
  29.         int arr2 = 0;
  30.  
  31.  
  32.         for (int i = arr2; i <= maxCounter; i++) {
  33.  
  34.             System.out.print(arr + " ");
  35.         }
  36.  
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top