List<int> lst = new List<int> { 1, 2, 4, 3, 5, 6, 7, 8,11,13,23,10,9,18 };
int first = int.MinValue;
int second = int.MinValue;
int result;
foreach (int i in lst)
{
if (i > first && i > second)
{
second = first;
first = i;
}
else if (i > second)
{
second = i;
}
}
result = second;
No comments:
Post a Comment