使用C++编写的数组元素排序的排名
在给定的问题中,我们需要对数组的所有给定元素进行排名,最小的数字具有最小的排名,最大的具有最大的排名。例如,我们还需要根据数字的频率来更改数字的排名 -
Input : 20 30 10 Output : 2.0 3.0 1.0 Input : 10 12 15 12 10 25 12 Output : 1.5, 4.0, 6.0, 4.0, 1.5, 7.0, 4.0 Here the rank of 10 is 1.5 because there are two 10s present in the given array now if we assume they both take different ranks i.e. 1 and 2 and we thus divide it within themselves so their rank becomes 1.5 and 1.5. Input : 1, 2, 5, 2, 1, 60, 3 Output : 1.5, 3.5, 6.0, 3.5, 1.5, 7.0, 5.0登录后复制