最大值很容易 ,就是统计最大值的个数我就转悠不过来了

解决方案 »

  1.   

    查出最大数后,定义一个计数器 int Count=0;,然后根据最大值再循环一遍,遇到与最大值相等的数,Count++
      

  2.   

    查出最大数后,定义一个计数器 int Count=0;,然后根据最大值再循环一遍,遇到与最大值相等的数,Count++
      

  3.   

    int[] arr = new int[6] { 1, 2, 3, 3, 3, 1 };
    int m=arr.Max();
    int Num=arr.Where(n=>n==m).Count();
      

  4.   

    var r=(from q in arr select q).Max();
    var result = arr.GroupBy(s => s).Select(s => new { Key = s.Key, Count = s.Count() });
      

  5.   

    int[] arr = new int[6] { 1, 2, 3, 3, 3, 1 };
    int m=arr.Max();
    int count=0;
    for(int i=0;i<arr.Length();i++)
    {
      count=i==m?count+1:count;
    }
    Console.WriteLine("{0}",count);
      

  6.   

    int [] NUM ={1,2,2,3,3,3,3,4,4,4}
    for (int i=0;i<  num.length;i++)
    if
    (max>num[0])输出max
    现在这个出来了  就是想统计max的个数
      

  7.   

    array.Where(n => n == array.Max()).Count()
      

  8.   

    循环,判断与MAX相同数
    LINQ最简便
      

  9.   


    int count=0;
    foreach (int number in num)
    {
      if(number==max)
        count++;
    }
    //输出count即可
    不过3楼的方法很简洁呀
      

  10.   

    int count=0;
    foreach (int number in NUM)
    {
      if(number==max)
      count++;
    }
    //输出count即可按照楼主的程序,是大写的NUM,笔误
      

  11.   

    int[] arr = new int[6] { 1, 2, 3, 3, 3, 1 };
    int maxValue=arr[0]; 
    int count=1;
    for(int i=1;i<arr.Length();i++)
    {
      if(maxValue<arr[i])
      {
         maxValue=arr[i];
         count=1;
      }
      else if(maxValue==arr[i])
         count++;
    }
    Console.WriteLine("{0}",count);