题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int index = s.indexOf(".");
String s1 = s.substring(0, index);
String s2 = s.substring(index + 1, s.length());
Double s3 = Double.valueOf(Integer.parseInt(s2));
for (int i = 0; i < s2.length(); i++) {
s3 *= 0.1;
}
if (s3 >= 0.5) {
System.out.println(Integer.parseInt(s1) + 1);
} else {
System.out.println(Integer.parseInt(s1));
}
}
}
#我的实习求职记录##实习,投递多份简历没人回复怎么办#
阿里云工作强度 612人发布
