这也能错?

B2016 浮点数向零舍入

QAQ5 @ 2025-01-04 11:52:04

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        BigDecimal f = scanner.nextBigDecimal();
        System.out.println(f.setScale(0, RoundingMode.FLOOR));
    }
}

by ChuanBoy_tlp @ 2025-01-10 09:37:14

这题其实还用不上BigDecimal来接收,直接用强转就可以了


|