写一个计算球质量的函数double mass(double density.double d),density是密度,d为球直径.利用该函数求直径10cm的铁球和15cm的金球的质量.已知铁的密度是7.86g/cm3,金的密度是19.3g/cm3.(注:球体积公式V=πd3/6).
2019-06-20
写一个计算球质量的函数double mass(double density.double d),density是密度,d为球直径.利用该函数求直径10cm的铁球和15cm的金球的质量.已知铁的密度是7.86g/cm3,金的密度是19.3g/cm3.(注:球体积公式V=πd3/6).
优质解答
#define PI 3.141592654
double mass(double density,double d)
{
return density * PI * d *d*d/6;
}
#define PI 3.141592654
double mass(double density,double d)
{
return density * PI * d *d*d/6;
}