题解 | #取近似值#
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
public static void main(String[] args) throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String str = reader.readLine(); String[] split = str.split("\\."); Integer i = Integer.parseInt(split[0]); double num = Double.parseDouble(str); if(num + 0.5 >= i + 1){ System.out.println(i+1); }else{ System.out.println(i); } }