int[] num = new int[] { 20, 19, 8, 9, 12 };
Например, в приведенном выше массиве мне нужно сравнить:
Две петли:
// Go through each element in turn (except the last one) for (int i = 0; i < num.Length - 1; i++) { // Start at the element after the one we're on, and keep going to the // end of the array for (int j = i + 1; j < num.Length; j++) { // num[i] is the current number you are on. // num[j] is the following number you are comparing it to // Compare num[i] and num[j] as you want } }