如何在没有 if 语句的情况下将数字四舍五入到最接近的十?例如,98 到 100。
int num = 87; double t; double d = 1.0 * num; // d = 87.0 t = d/100; System.out.println(t);
您可以使用Math.round(num/10.0) * 10.
Math.round(num/10.0) * 10