PROGRAM public void max(int sample[]) { int elements = 1; boolean b = false; for (int i = 1; i < sample.length; i++){ for (int j = 0; j < i; j++){ if (sample[j] == sample[i]) { b = true; j = i-1; } } if (b == false) elements++; b = false; } int places[] = new int[elements]; int times[] = new int[elements]; places[0] = 0; int x = 1; for (int i = 1; i < sample.length; i++) { if (sample[i] == sample[0]) x++; } times[0] = x; int y = 1; for (int i = 1; i < sample.length; i++) x = 1; for (int j = 0; j < i; j++) { if (sample[j] == sample[i]) { b = true; j = i-1; } } if (b == false) { for (int k = i+1; k < sample.length; k++) { if (sample[k] == sample[i]) x++; } places[y] = i; times[y] = x; y++; } b = false; } if (y < places.length) { places[places.length-1] = sample.length-1; times[times.length-1] = 1; } int max; for (int i = 0; i < times.length || b == true; i++) { max = i; b = true; for (int j = 0; j < times.lenth; j++) { if (times[j] > times[i]) { b = false; j = times.length - 1; } } } boolean isMax[] = new boolean[times.length]; for (int i = 0; i < times.length; i++) { if (times[i] == times[max]) isMax[i] = true; else isMax[i] = false; } System.out.print("Gli elementi che appaiono pił volte sono: ") for (int i = 0; i < isMax.length; i++) { if (isMax[i]) System.out.print(sample[places[i]] " "); } System.out.println(); }