-
Title Description:
-
Enter the center point of the ball and the coordinates of a point on the ball to calculate the radius and volume of the ball
-
Input:
The
-
center point of the ball and the coordinates of a point on the ball are entered in the following form: x0 y0 z0 x1 y1 Z1
-
Output:
-
input may have multiple groups, for each set of inputs, the radius and volume of the output ball, and the result retains three decimal places
-
Sample input:
-
-
Sample output:
-
1.732 21.766
-
Tips:
-
To avoid accuracy problems, use Arccos (-1) for PI values.
#include <iostream>#include<math.h>#include<iomanip>using namespacestd;intMain () {Doublex1,x2,y1,y2,z1,z2; while(cin>>x1>>y1>>z1>>x2>>y2>>Z2) { DoubleR= (X1-X2) * (X1-X2) + (y1-y2) * (y1-y2) + (Z1-Z2) * (z1-z2); R=sqrt (R); Doublev=4/3*acos (-1) *r*r*R; cout<<fixed<<setprecision (3) <<r<<" "<<v<<Endl;} return 0;}
1068. Radius and volume of the ball