标签:
#include <stdio.h>
#include <math.h>
#define PI 3.1415927
int main()
{
    double r,vol;
    while (scanf ("%lf",&r)!=EOF)
    {
        vol=4.0/3*PI*r*r*r;//There is 4.0,isn‘t 4!!
        printf ("%.3f\n",vol);
    }
    return 0;
}
这里必须是4.0而不是4,如果是4的话将不能得到想要的浮点数结果,结果的小数位上将全为零,这显然与我们所期望的结果不同。
标签:
原文地址:http://www.cnblogs.com/lss-bistu/p/4817815.html