public static void main(String[] args) { int a[]={11,44,55,22,44,44,33};
test(a); }
}
import java.util.Arrays; public class Test{ public static void main (String[] args) { int a[]={11,44,55,22,44,44,33}; Arrays.sort(a); int i=a.length-1; int j=a.length-2; while(j>=0&&a[i]!=a[j]){ i--;j--; } if(j>=0){ while(j>=0&&a[i]==a[j]) j--; System.out.println("最大的有重复的数是:"+a[i]+" 重复的次数是:"+(i-j)); }else{ System.out.println("不存在重复的数!"); } }}
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class TestCy {
public static Map getInt(int[] a) {
Map map = new HashMap(); for (int i = 0; i < a.length ; i++) {
if (map.get(a[i]) == null) {
map.put(a[i], 1);
} else {
map.put(a[i], ((Integer) map.get(a[i])) + 1);
}
}
return map;
}
public static void test(int[] a){
Map map = getInt(a);
Object[] arr = map.values().toArray();
Arrays.sort(arr);
Iterator iterator= map.entrySet().iterator();
while(iterator.hasNext()){
Map.Entry entry = (Map.Entry)iterator.next();
if(entry.getValue()==arr[arr.length-1]){
System.out.println(entry.getKey().toString()+"---"+arr[arr.length-1]);
}
}
}
public static void main(String[] args) {
int a[]={11,44,55,22,44,44,33};
test(a); }
}
public class Test{
public static void main (String[] args) {
int a[]={11,44,55,22,44,44,33};
Arrays.sort(a);
int i=a.length-1;
int j=a.length-2;
while(j>=0&&a[i]!=a[j]){
i--;j--;
}
if(j>=0){
while(j>=0&&a[i]==a[j]) j--;
System.out.println("最大的有重复的数是:"+a[i]+" 重复的次数是:"+(i-j));
}else{
System.out.println("不存在重复的数!");
}
}}