计算球体积
来源:互联网 发布:淘宝怎样秒杀 编辑:程序博客网 时间:2024/05/16 06:11
计算球体积
时间限制:3000 ms | 内存限制:65535 KB
难度:1
- 描述
- 根据输入的半径值,计算球的体积。
- 输入
- 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。(0<R<100)
- 输出
- 输出对应的球的体积,对于每组输入数据,输出一行,计算结果四舍五入为整数
Hint:PI=3.1415926 - 样例输入
11.5
- 样例输出
414
- 来源
- Trinity
- 上传者
- 张洁烽
代码:
#include <iostream> #include <stdio.h> #include <string.h> #include <math.h> #include <vector> #include <queue> #include <stack> #include <map> #include <string> #include <algorithm> #include <iomanip>#define PI 3.1415926using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) {/*freopen("file/input.txt","r",stdin);freopen("file/output.txt","w",stdout);*/double r;while(scanf("%lf",&r) != EOF){//cout<<4*PI<<endl;//cout<<r<<endl;printf("%.0f\n",4*PI*r*r*r/3);}return 0;}
代码分析:本来想
printf("%.0f\n",4*PI*r*r*r/3);直接改为
printf("%d\n",4*PI*r*r*r/3);,将浮点结果直接按照整数输出,结果WA了。这样是不行的即双浮点数printf输出格式上必须要保证是lf。
阅读全文
0 0
- 2002 计算球体积
- 2002 计算球体积
- 2002 计算球体积
- 计算球体积
- 计算球体积
- hdoj_2002 计算球体积
- 【计算球体积 242】
- 计算球体积
- 【2002 计算球体积】
- 计算球体积
- 计算球体积
- 计算球体积(2002)
- 2002 计算球体积
- 计算球体积
- 242 计算球体积
- hdu2002计算球体积
- HDOJ计算球体积
- HDU2002 计算球体积
- MyBatis中的结果集映射---xml配置文件
- 循环矩阵傅里叶对角化
- oracle数据库报表取数---存储过程方式
- 题解LeetCode UglyNumber
- [LeetCode] 74. Search a 2D Matrix
- 计算球体积
- POJ 2036 I Conduit! 笔记
- 阿里云 socket 服务器配置
- java自用
- ArcGIS Viewer for Flex简易教程
- ZOJ 1383
- Java 自定义 ClassLoader 实现隔离运行不同版本jar包的方式
- ijkplayer详解使用教程
- 关于新创建一个虚拟机以及多台机器ssh无密登录的一些细节问题补充