1
public
static
int
[] GetTheManyMaxValues(
int
[] arr,
int
number)
2 {
3 if (arr == null || number <= 0 || arr.Length < number) return null ;
4 List < int > lst = new List < int > ();
5 for ( int i = 0 ; i < number; i ++ )
6 {
7 lst.Add(arr[i]);
8 }
9 for ( int i = number; i < arr.Length; i ++ )
10 {
11 int min = GetTheMinValue(lst);
12 if (min < arr[i])
13 {
14 lst.Remove(min);
15 lst.Add(arr[i]);
16 }
17 }
18 return lst.ToArray();
19 }
2 {
3 if (arr == null || number <= 0 || arr.Length < number) return null ;
4 List < int > lst = new List < int > ();
5 for ( int i = 0 ; i < number; i ++ )
6 {
7 lst.Add(arr[i]);
8 }
9 for ( int i = number; i < arr.Length; i ++ )
10 {
11 int min = GetTheMinValue(lst);
12 if (min < arr[i])
13 {
14 lst.Remove(min);
15 lst.Add(arr[i]);
16 }
17 }
18 return lst.ToArray();
19 }
1
public
static
int
GetTheMinValue(List
<
int
>
lst)
2 {
3 int min = lst[ 0 ];
4 foreach ( int number in lst)
5 {
6 if (min > number)
7 {
8 min = number;
9 }
10 }
11 return min;
12 }
2 {
3 int min = lst[ 0 ];
4 foreach ( int number in lst)
5 {
6 if (min > number)
7 {
8 min = number;
9 }
10 }
11 return min;
12 }