题解 | #牛牛的水杯#
牛牛的水杯
http://www.nowcoder.com/practice/c196c47c23394bf3bdd4f82a838df6bf
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double PI = 3.14;
int h = scanner.nextInt();
int r = scanner.nextInt();
//一杯水的体积
double v = PI * h * r * r;
//1立方厘米 == 1毫升 == 0.001升
//10升 == 10000毫升
if(10000 % v == 0) {
System.out.println(10000 / (int)v);
} else {
System.out.println(10000 / (int)v + 1);
}
}
}
Java基础练习题 文章被收录于专栏
都是一些基础的语法题目,每天可以刷几道。