hdu2002

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2002
注意提示
#define PI 3.1415927
这里的π值有七位小数。
而float只有六位有效数字。在要求7位的π值情况下,要获得准确的计算结果,必须使用double类型。
代码:

#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415927

double a, ans;

int main(){
    
    
	while(cin >> a){
    
    
		ans = 4 * PI * a * a * a / 3;
		printf("%.3lf\n", ans);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/LXC_007/article/details/113780063