2002

计算球体体积

 1 #include <stdio.h>
 2 #define PI 3.14
 3 int main()
 4 {
 5     double r,v;
 6     while(scanf("%lf",&r))
 7     {
 8         v = (3.0/4)*PI*r*r*r;
 9         //除法最好留在最后算
10         printf(".3%lf
",v);
11     }
12     return 0;
13 }

参考c++

 1 #include <math.h>
 2 #include <stdio.h>
 3 
 4 #define PI 3.1415927
 5 
 6 int main(void)
 7 {
 8     double r;
 9 
10     while (scanf("%lf", &r) != EOF)
11         printf("%.3lf
", 4.0*PI*r*r*r/3.0);
12 
13     return 0;
14 }
========================if i have some wrong, please give me a message, thx.========================
原文地址:https://www.cnblogs.com/ailx10/p/5325535.html