ACM 第七题

计算球体积
Time limit 1000 ms
Memory limit 32768 kB
OS Windows

根据输入的半径值,计算球的体积。

Input
输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。

Output
输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。

Sample Input
1
1.5

Sample Output
4.189
14.137

Hint
#define PI 3.1415927

问题链接:https://vjudge.net/problem/hdu-2002
问题简述:计算球的体积。
问题分析:v=(4.0/3.0) * pi* r *r *r

AC通过的C语言程序如下:

#include<iostream>
#include<iomanip>
#define PI 3.1415927
using namespace std;
int main()
{
	double a;
	while (cin >> a)
	{
		cout << setiosflags(ios::fixed) << setprecision(3) << 4.0 / 3.0*PI*a*a*a << endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43973938/article/details/84874266