Find the average. largest, smallest number and mode of a int array

后端 未结 3 1775
耶瑟儿~
耶瑟儿~ 2021-01-29 17:01

Hi I am trying to make a program where the user can enter up to 25 numbers and then it tells the user the average, smallest and largest number and the mode of the numbers entere

3条回答
  •  一向
    一向 (楼主)
    2021-01-29 17:17

    var smallest = AverageArray.Min();
    var largest = AverageArray.Max();
    var mode = AverageArray.GroupBy(v => v)
                .OrderByDescending(g => g.Count())
                .First()
                .Key;
    

提交回复
热议问题