- I have 2 arrays named
Arr1
andArr2
in C#. They are of the exact same dimensions...
I need to get the element of Arr1 corresponding to maximum of elements in Arr2 beginning with given indices ...
e.g
Get indices of the max of Arr2 [ 1 , 10 , 3 , i , j ]
for all i
,j
Return Arr1 [ 1 , 10 , 3 , i , j ]
Of course I need the elegant solution (not the "loop for them" one...)
Please Note:
I do not want to loop through the arrays, because it is 11 dimensional!!.. the code will be ugly and error prone.. and I may run out of variable names :)
EDIT:
The normal solution would be:
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
if(Arr2[1,10,3,maxi,maxj]<Arr2[1,10,3,i,j])
{
maxi=i
maxj=j
}
return Arr1[1,10,3,maxi,maxj];
But I need to do it in less and more beautiful code.. may be using querys or linq..