int[] array= new int[]{12,13,24,45,65,27,37,43,41,50,75,68}; var item = array.OrderByDescending(x=>x).Skip(2).Take(1).ToList(); foreach(int it in item) Console.WriteLine(it);
var result = from n in number orderby n descending select n; var value = result.ToList().ElementAt(2);
class Test{public int Third_higest(int[] array){// int[] array = new int[12] { 12, 13, 67, 45, 65, 27, 37, 43, 41, 50, 75, 68 };int arrLen = array.Length - 1;int indexofi = 0, temp = 0, count = 0, indexofj = 0, index = 0, breakpoint = 0;while (true){if (indexofj == arrLen){if (indexofi != arrLen){indexofi++;}if (count == 3){break;}indexofj = 0;}if (array[indexofi] < array[indexofj + 1]){temp = array[indexofi];array[indexofi] = array[indexofj + 1];array[indexofj + 1] = temp;temp = array[indexofi];indexofj++;}else{indexofj++;}if (temp != 0 && indexofj == arrLen && indexofi == count){array[indexofi] = 0;count++;}// if (arrLen == index)// {// if (breakpoint == 0)// {// break;// }// index = 0;// breakpoint = 0;// }// if (array[index] < array[index + 1])// {// int tmp = array[index];// array[index] = array[index + 1];// array[index + 1] = tmp;// breakpoint = 1;// }// index++;// temp++;//}}return temp;}}class Program{static void Main(string[] args){Test test = new Test();int[] array = new int[12] { 12,13,24,45,65,27,37,43,41,50,75,68};int arrayOut = test.Third_higest(array);Console.WriteLine(arrayOut);Console.ReadLine();}}
for (var i = 1; i < array.Length;){if (i != 0 && (array[i] < array[i - 1])){var temp = array[i];array[i] = array[i - 1];array[i - 1] = temp;i--;}else { i++; }}
public int thirdlargestValue(){int first, second, third = 0;int[] arr = { 12, 13, 24, 45, 65, 27, 37, 43, 41, 50, 75, 68 };first = arr[0];second = arr[1];third = arr[2];for (int i = 0; i < arr.Length; i++){if (arr[i] > first){third = second;second = first;first = arr[i];}else if (arr[i] > second){third = second;second = arr[i];}else if (arr[i] > third){third = arr[i];}}return third;}
int[] nums = new int[] {12,13,24,45,65,27,37,43,41,50,75,68}var result = (from s in numsselect s).skip(2).first();
for(int i=0;i<=array.Length-1;i ) {if(array[i] 0
public void GetThirdHigestNumber(){int[] array = { 12, 13, 24, 45, 65, 27, 37, 43, 41, 50, 75, 68 };var objResult = array.OrderByDescending(x => x).ToList().Take(3);int thirdHighestNumber = 0;foreach (int num in objResult){thirdHighestNumber = num;}Console.WriteLine("Third Hieghest Number : {0}", thirdHighestNumber);}
public static int thirdLargestNumber(int[] numbers){for(int i=0;i 0
int iCount = 0;int[] array = new int[12] { 12, 13, 24, 45, 65, 27, 37, 43, 41, 50, 75, 68 };for (int i = 0; i <= array.Length; i++){for (int j = i + 1; j < array.Length; j++){if (array[i] > array[j]){iCount = array[i];array[i] = array[j];array[j] = iCount;}}}Console.WriteLine(array[2]);
int[] arr={12,13,24,45,65,27,37,43,41,50,75,68};var q = arr.OrderByDescending(a => a).ToArray();for (int i = 0; i < q.Count(); i++ ){if (i == 2){Console.WriteLine(q[i].ToString());break;}}