using System.IO;
using System;
using System.Linq;
class Program
{
static void Main()
{
var a=new int[6]{1,10,5,7,4,3};
int max1=a.Max(); //MAX
int max2=a.Min(); //MIN
int max3=a.OrderByDescending(z=>z).Skip(1).First();
//Second MAX
int max4=a.OrderBy(z=>z).Skip(1).First();
//Second MIN
Console.WriteLine("{0}",max1);
Console.WriteLine("{0}",max2);
Console.WriteLine("{0}",max3);
Console.WriteLine("{0}",max4);
Console.WriteLine("Hello, World!");
}
}
Output:-
10
1
7
3
using System;
using System.Linq;
class Program
{
static void Main()
{
var a=new int[6]{1,10,5,7,4,3};
int max1=a.Max(); //MAX
int max2=a.Min(); //MIN
int max3=a.OrderByDescending(z=>z).Skip(1).First();
//Second MAX
int max4=a.OrderBy(z=>z).Skip(1).First();
//Second MIN
Console.WriteLine("{0}",max1);
Console.WriteLine("{0}",max2);
Console.WriteLine("{0}",max3);
Console.WriteLine("{0}",max4);
Console.WriteLine("Hello, World!");
}
}
Output:-
10
1
7
3
No comments:
Post a Comment