Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int[] mas = {1, 1, 5, 5};
- int maxCount = 0;
- String maxNumCount = "none";
- for (int i = 0; i < mas.length; i++) {
- int count = 0;
- for (int j = 0; j < mas.length; j++) {
- if (mas[i] == mas[j]) {
- count++;
- }
- }
- if (count > maxCount) {
- maxCount = count;
- maxNumCount = "" + mas[i];
- } else if (count == maxCount && !maxNumCount.equals("" + mas[i])) {
- maxNumCount = "none";
- maxCount = count;
- }
- }
- if (maxNumCount.equals("none")) {
- System.out.println(0);
- } else {
- System.out.println(maxCount);
- }
- System.out.println(maxNumCount);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement