/**
* @ClassName: Test
* @Description:学生成绩排名(排名方式一)
* 以Map的形式返回
*/
public class TestRank {
public static Map<Double, Integer> getRank(List<Double> oldList){
Map<Double, Integer> returnMap = new HashMap<Double, Integer>();
for(Double oldOne : oldList){
int count = 0;
for(Double newOne : oldList){
if(newOne > oldOne){
count++;
}
}
returnMap.put(oldOne, count+1);
}
return returnMap;
}
public static void main(String[] args) {
Double[] arr = new Double[] { 90.0, 80.5, 85.5, 83.0, 85.0, 75.0, 75.0, 75.0, 60.0, 65.0 };
Map<Double, Integer> map = getRank(Arrays.asList(arr));
System.out.println(map);
}
}
转载于:https://my.oschina.net/wusong4232/blog/634701