计算球体积 HDU - 2002

Text Reverse
Time limit 1000 ms
Memory limit 32768 kB
OS Windows
Source C语言程序设计练习(一)

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

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

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

Sample Input
1
1.5

Sample Output
4.189
14.137

Hint
#define PI 3.1415927

问题链接HDU - 2002

问题简述:
根据输入的半径值,计算球的体积。

问题分析:
做一个球的体积的计算,计算结果保留三位小数。

程序说明:
输入半径r,通过计算求出球的体积v,通过printf("%.3lf\n", s)实现保留三位小数。

#include
using namespace std;
#define PI 3.1415927

int main()
{
double r,v;
while (cin >>r)
{
v = 4.0 / 3 * PIrr*r;
printf("%.3lf\n", s);
}
return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44012551/article/details/84884005