收获:在double或者float的情况下,常数也应该有小数点。比如4/3.0
#include "stdio.h" #include <math.h> #define PI 3.1415927 int main() { double r,v; while(scanf("%lf",&r)!=EOF) { v=(4/3.0)*PI*r*r*r; printf("%.3lf\n",v); } }
收获:在double或者float的情况下,常数也应该有小数点。比如4/3.0
#include "stdio.h" #include <math.h> #define PI 3.1415927 int main() { double r,v; while(scanf("%lf",&r)!=EOF) { v=(4/3.0)*PI*r*r*r; printf("%.3lf\n",v); } }