C - calculated volume of a sphere HDU - 2002
The input radius, the sphere volume calculation.
Input
A plurality of input data sets, each one row, each row including a real number, the radius of the sphere.
Output
Corresponding to the output volume of the ball, for each set of input data, output line, the calculation result three decimal places.
Sample Input
1 1.5
Sample Output
4.189 14.137
Hint
#define PI 3.1415927
Code Example:
#include<stdio.h>
#define PI 3.1415927
int main(){
double r,v; //在这里要注意精度的问题
while(scanf("%lf",&r)!=EOF){
v=4*PI*r*r*r/3;
printf("%.3lf\n",v);
}
}
Hint PI has given seven decimal, we must pay attention to the corresponding accuracy when writing a program, you want accurate results calculated here use the double type.