int[] arr1 = new int[8] { 10, 5, 15, 11, 2, 0, 9, 7 }; int firstHighestNumber1 = arr1[0]; int secondHighestNumber1 = arr1[0]; int thirdHighestNumber = arr1[0]; for (int i1 = 0; i1 < arr1.Length; i1++) { if (arr1[i1] > firstHighestNumber1) { firstHighestNumber1 = arr1[i1]; } } for (int x = 0; x < arr1.Length; x++) { if (arr1[x] > secondHighestNumber1 && firstHighestNumber1 != arr1[x]) { if (arr1[x] < secondHighestNumber1) { secondHighestNumber1 = arr1[x]; } } } for (int y = 0; y < arr1.Length; y++) { if (arr1[y] > thirdHighestNumber && secondHighestNumber1 != arr1[y]) { thirdHighestNumber = arr1[y]; } }
firstnumber=15 seconfnumber=11 thirdnumber=10
int[] arr = { 10, 20, 10, 15, 25, 30, 11 }; arr = arr.Distinct().ToArray(); Array.Sort(arr); Array.Reverse(arr); int first = arr[0]; int secont = arr[1]; int third = arr[2];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)