Just to show you there are many ways to do it, here is one with tuples:
int[] arr1 = {1,3,8};
int[] arr2 = {2,5,3};
int[] arr3 = {3,7,7};
int[][] arrays = {arr1,arr2,arr3};
int arraySize = arr1.Length;
int nArrays = arrays.Length;
for (int d = 0; d < arraySize; d++)
{
var list = new List<(int index,int value)>() {};
for (int i = 0; i < nArrays; i++)
{
list.Add((index:i, value:arrays[i][d]));
}
list.Sort((i1,i2)=>i2.value.CompareTo(i1.value));
Console.Out.Write($"Index {d}: ");
for (int x = 0; x<nArrays-1; x++)
{
Console.Out.Write($"{list[x].value} from array {list[x].index} is greater than ");
}
Console.WriteLine($"{list[nArrays-1].value} from array {list[nArrays-1].index}");
}
It produces a List of tuples of index and value, then sorts by value and uses the result to output the desired text. It ought to scale to more arrays and values. I tried to find a more elegant way to produce the list, but I haven't found one yet.
It produces this output:
Index 0: 3 from array 2 is greater than 2 from array 1 which is greater than 1 from array 0
Index 1: 7 from array 2 is greater than 5 from array 1 which is greater than 3 from array 0
Index 2: 8 from array 0 is greater than 7 from array 2 which is greater than 3 from array 1
I was also confused about the > sign in the output.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…