题解 | #四舍五入#
四舍五入
https://www.nowcoder.com/practice/cae89de6292b4084acb93659353260e0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double d = in.nextDouble(); int i = (int)(d + 0.5); System.out.print(i); } }
只需要将d再加个0.5即可
然后再强制数据转换,直接截断。