2019独角兽企业重金招聘Python工程师标准>>>
在实际开发中可能遇到这样的预约 比如
4.3显示4.5
4.5显示5
3.1显示3
4.2显示4
具体算法如下
// service_rating为积分分数
if (service_rating>4.5){ return 5;
}else { float s=service_rating*2;
s= (float) (Math.round(s)/2.0); return s;
}
通过该算法就可以实现上面的功能
简单的一个过程
比如4.2分
4.2*2=8.4
8.4四舍五入为8
然后8除以2.0
最终为4
大家看明白了吗