import java.util.Scanner; import static java.lang.Math.PI; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); while (m != 0) { double x1 = sc.nextDouble(); double y1 = sc.nextDouble(); double z1 = sc.nextDouble(); double x2 = sc.nextDouble(); double y2 = sc.nextDouble(); double z2 = sc.nextDouble(); Ball b = new Ball(); b.setRadius(x1, x2, y1, y2, z1, z2); System.out.println(b.toString()); //限制精度后 m--; } } } class Geometry { protected double side; protected double volume; public Geometry() {} public void setSide(double side) { this.side = side; } public double getSide() { return side; } public double getVolume() { volume = side * side * side; return volume; } } class Ball extends Geometry{ private double x1, x2, y1, y2, z1, z2; private double radius; private double volume; public Ball(){} public void setRadius(double x1, double x2, double y1, double y2, double z1, double z2) { this.x1 = x1; this.y1 = y1; this.z1 = z1; this.x2 = x2; this.y2 = y2; this.z2 = z2; } public double getRadius() { return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2) + Math.pow((z2 - z1), 2)); } public double getVolume() { return (4.0 / 3.0) * PI * Math.pow(getRadius(), 3); } @Override public String toString() { return String.format("%.2f", getRadius()) + " " + String.format("%.2f", getVolume()); } }
import java.text.DecimalFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); for (int i = 0; i <m; i++) { int x1 = scanner.nextInt(); int y1 = scanner.nextInt(); int z1 = scanner.nextInt(); int x2 = scanner.nextInt(); int y2 = scanner.nextInt(); int z2 = scanner.nextInt(); double r = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)+Math.pow(z1-z2,2)); double v = 4.0/3*Math.PI*Math.pow(r,3); DecimalFormat f = new DecimalFormat("0.00"); System.out.println(f.format(r)+" "+f.format(v)); } } }