题解 | #四舍五入#
四舍五入
https://www.nowcoder.com/practice/cae89de6292b4084acb93659353260e0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double d = scanner.nextDouble();
//write your code here......
int i = 0;
if (d > 0) {
i = (int)(d + 0.5);
} else {
i = (int)(d - 0.5);
}
System.out.println(i);
}
}
#小白编程入门#
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double d = scanner.nextDouble();
//write your code here......
int i = 0;
if (d > 0) {
i = (int)(d + 0.5);
} else {
i = (int)(d - 0.5);
}
System.out.println(i);
}
}
#小白编程入门#