I want to rank an array such as the following:
mat[0] = 300
mat[1] = 200
mat[2] = 360
mat[3] = 230
mat[4] = 290
The rank depends on the array above (max number gets rank 1 etc.):
rank[0] = 2
rank[1] = 5
rank[2] = 1
rank[3] = 4
rank[4] = 3
How do I rank without moving the array in any kind of sorting algorithm or by having different input:
mat[0] = 400
mat[1] = 100
mat[2] = 220
mat[3] = 230
mat[4] = 50
the rank would be:
rank[0] = 1
rank[1] = 4
rank[2] = 3
rank[3] = 2
rank[4] = 5
How would I do this in C?