题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // while(in.hasNextLine()){ float n = in.nextFloat(); int out = new BigDecimal(n).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); System.out.println(out); // } in.close(); } }