if ((double) (points / tries) > hiScore) {
hiScore = (double) points / tries;
hiPoints = points;
hiTries = tries;
我无法理解为什么hiScore,甚至是积分/尝试,总是保持= 0(积分和尝试都是整数,与hiPoints和hiTries相同)
答案 0 :(得分:0)
试试这个
_
甚至这个(不应该是必要的,因为优先级转换操作已经过度划分):
if ( ((double) points / tries) > hiScore) {
hiScore = (double) points / tries;
hiPoints = points;
hiTries = tries;
你需要在除法运算之前转换整数变量。