题解 | 球的半径和体积
球的半径和体积
https://www.nowcoder.com/practice/4b733a850c364c32b368555c8c2ec96b
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int x0 = in.nextInt();
int y0 = in.nextInt();
int z0 = in.nextInt();
int x1 = in.nextInt();
int y1 = in.nextInt();
int z1 = in.nextInt();
double r = Math.sqrt(Math.pow(x1-x0,2) + Math.pow(y1-y0,2) + Math.pow(z1-z0,2));
double v = 4.0 / 3 * Math.acos(-1) * Math.pow(r,3);
System.out.printf("%.3f %.3f",r,v);
}
}
}