题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] strings = line.split("\\."); int anInt1 = Integer.parseInt(strings[0]); if (Integer.parseInt(strings[1].substring(0, 1))>=5){ anInt1++; } System.out.println(anInt1); br.close(); } }
#写出一个程序接受一个正浮点数值输出该数值的近似整数值如果小数点后数值大于等于5向上取整小于5则向下取整importsys#