题解 | #取近似值#
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
我是菜鸡,这种写法还有谁。。。。
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
float a = sc.nextFloat();
String a1 = Float.toString(a);;
String[] s = a1.split("\\.");
char c = s[1].charAt(0);
char[] d ={c};
int e =Integer.parseInt(new String(d));
if(e>=5){
System.out.println((int)a + 1);
}else{
System.out.println((int)a );
}
}
}
}
}