1. 程式人生 > >hdu2002 計算球體積【C++】

hdu2002 計算球體積【C++】

amp problem color ott The panel sca std cep

計算球體積

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 194043 Accepted Submission(s): 76838


Problem Description 根據輸入的半徑值,計算球的體積。

Input 輸入數據有多組,每組占一行,每行包括一個實數,表示球的半徑。

Output 輸出對應的球的體積,對於每組輸入數據,輸出一行,計算結果保留三位小數。

Sample Input 1 1.5

Sample Output 4.189 14.137 Hint
#define PI 3.1415927
 1 #include<cstdio>
 2 const double PI =  3.1415927;
 3 int main()
 4 {
 5     double r;
 6     while(scanf("%lf",&r)!=EOF)
 7     {
 8         double v = (1.0)*4/3*PI*r*r*r;
 9         printf("%.3f\n",v);
10     }
11     return 0;
12 }

hdu2002 計算球體積【C++】