由键盘输入一串正整数  例如:3 2 1 4 5 4 5 3 3
首先进行排序,可排序为1 2 3 3 3  4 4 5 5
3的重复次数为3次  4 5 的重复次数为2次 
则输出应该 为 3 3 3  若最大重复次数有若干个数字相同 则分别输出要求JAVA去实现 
提示:声明数组可以用表达式 输入数字的个数可以在表达式中出现

解决方案 »

  1.   

    插入数据库 分组统计一下就可以了 group by
      

  2.   

    package net.oicp.sunflowerbbs;public class Hash { public static void hashCount(int [] a)
    {
    int max=a[0];
    for(int i=1;i<a.length;i++)
    max=max<a[i]?a[i]:max;
    int hashTable[]=new int[max+1];
    for(int i=0;i<a.length;i++)
    hashTable[a[i]%(max+1)]=hashTable[a[i]%(max+1)]+1;
    int countMax=hashTable[0];
        for(int i=0;i<hashTable.length;i++)
         countMax=countMax<hashTable[i]?hashTable[i]:countMax;
        for(int i=0;i<hashTable.length;i++)
        {
         if(hashTable[i]==countMax)
         {
           for(int j=0;j<countMax;j++)
            System.out.print(i+(j!=countMax-1?",": ""));
           System.out.println();
         }
        }
        
    }
    public static void main(String[] args) {            int b[]={1,20,80,20,80,1,30,30,30};
                hashCount(b); }}
      

  3.   

    String str = "3 2 1 4 5 4 5 3 3 4 5 4";
    String[] arr = str.split("\\s+");
    int[] p = new int[arr.length];
    for(int i=0;i<p.length;i++)p[i]=new Integer(arr[i]).intValue();
    for(int i=0;i<p.length;i++){
    for(int j=i+1;j<p.length;j++){
    if(p[i]>p[j]){
    int mid = p[i];
    p[i] = p[j];
    p[j] = mid;
    }
    }
    }
    for(int i=0;i<p.length;i++)System.out.print(p[i]+" ");
    System.out.println();
    String ret = "";
    int cnt = 0;//当前数字最多位
    for(int i=0,j=1;i<p.length-1;i++,j++){
    //判断分界点
    if(p[i]==p[i+1] && i == p.length-2){
    if(cnt == j+1){
    ret += ","+p[i];
    }else if(cnt == j-1){
    ret = p[i]+"";
    }
    }else if( p[i]!=p[i+1] ){
    if(j>cnt){
    ret = p[i]+"";
    cnt = j;
    }else if(j == cnt){
    ret += ","+p[i];
    }
    j=0;
    }
    }
    System.out.println(ret);
      

  4.   

    先排序,每个数都查下了,2个FOR循环,
      

  5.   

    public class Program {
    public static void main(String[] args)
        {
    int[] a = new int[100];
    int[] s = new int[101];
    int maxtime = 0,maxvalue = 0;
    for(int i = 0;i < 100;i++)
    {
    a[i] = (int)(Math.random()*(100)+1);
    }
    for(int y = 0;y < 100;y++)
    {
    s[a[y]-1]++;
    }
    for(int k = 0;k < 100;k++)
    {
    if(maxtime < s[k])
    {
    maxtime = s[k];
    maxvalue = k+1;
    }
    if(maxtime == s[k])
    {
    if(maxvalue < k+1)
    maxvalue = k+1;
    }
    }
    System.out.println("随机产生的100个数字如下:");
    for(int l=0;l<100;l++)
    {
    System.out.println("第"+(l+1)+"个数 = "+ a[l]);
    } System.out.println("随机最多出现"+maxtime+"次,此数字为"+maxvalue);