-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo37.cs
51 lines (47 loc) · 1.27 KB
/
algo37.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace HelloWorld
{
class Program
{
public static int Stray(int[] numbers)
{
int counter = 0;
int counter2 = 0;
for (int i = 0; i < numbers.Length; i++)
{
if (numbers[i] == numbers.Min())
{
counter++;
if (counter > 1)
{
if (numbers.Max() >= 3)
{
return numbers.Max();
}
}
}
if (numbers[i] == numbers.Max())
{
counter2++;
if (counter2 > 1)
{
return numbers.Max();
}
if (numbers.Min() >= 3)
{
return numbers.Min();
}
}
}
return 0;
}
static void Main(string[] args)
{
int[] x = { 1, 1, 1, 1, 2 };
Console.WriteLine(Stray(x));
}
}
}