Skip to content

Commit 3295269

Browse files
author
lanyuanxiaoyao
committed
修改文件: _posts/2014-09-12-caculate-ball.md
1 parent 8139da4 commit 3295269

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

_posts/2014-09-12-caculate-ball.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
layout: post
3+
title: 2002.计算球体积
4+
date: 2014-09-12 21:36
5+
categories: 杭电HDU
6+
tags: [杭电HDU]
7+
---
8+
## Problem
9+
>**Problem Description**
10+
根据输入的半径值,计算球的体积。
11+
**Input**
12+
输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。
13+
**Output**
14+
输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。
15+
**Sample Input**
16+
1
17+
1.5
18+
**Sample Output**
19+
4.189
20+
14.137
21+
**Hint**
22+
```#define PI 3.1415927```
23+
24+
## Solution
25+
```cpp
26+
#include<stdio.h>
27+
#define PI 3.1415927
28+
int main(void)
29+
{
30+
double r,tiji;
31+
32+
while(scanf("%lf",&r)!=EOF){
33+
tiji=(4*r*r*r*PI)/3;
34+
printf("%.3lf\n",tiji);
35+
}
36+
return 0;
37+
}
38+
```

0 commit comments

Comments
 (0)