[2003]:求绝对值
来源:互联网 发布:河鱼软件 编辑:程序博客网 时间:2024/05/16 15:01
求绝对值
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 94299 Accepted Submission(s): 46607
Problem Description
求实数的绝对值。
Input
输入数据有多组,每组占一行,每行包含一个实数。
Output
对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。
Sample Input
123
-234.00
Sample Output
123.00
234.00
第一种方法:直接法
#include<stdio.h>int main(){ double i; while(scanf("%lf", &i)!=EOF){ if(i<0){ printf("%.2f\n", (-1)*i); } else{ printf("%.2f\n", i); } } return 0;}
第二种方法:求绝对值函数
头文件:#include<math.h>> int 型>int abs(int x);>long 型>long labs(int x);>浮点数 float double>double fabs(double x);
#include<stdio.h>#include<math.h>int main(){ double i; while(scanf("%lf", &i)!=EOF){ printf("%.2f\n", fabs(i)); } return 0;}
0 0
- 2003 求绝对值
- hdu 2003 求绝对值
- HDU 2003 求绝对值
- 2003 求绝对值
- 2003 求绝对值
- HDU 2003 求绝对值
- hdu-2003-求绝对值
- HDU 2003 - 求绝对值
- 求绝对值(2003)
- HDU 2003 求绝对值
- [hdu 2003] 求绝对值
- HDU-2003 求绝对值
- 2003 求绝对值
- HDOJ 2003 求绝对值
- HDU 2003 求绝对值
- HDU 2003 求绝对值
- HDU 2003 求绝对值
- HD 2003 求绝对值
- An Architecture for Fast and General Data Processing on Large Clusters
- 清华EMBA课程系列思考之二 -- 清华探究及信息战略与管理
- jquery Datatable参数及使用方法
- Swift Cheat Sheet [2] - Control Flow
- Int VS Integer
- [2003]:求绝对值
- sql---整点查询的sql
- 在UILabel中 显示文字和图片
- jsp写一个计时器
- Xamarin.Forms入门困扰与解决方式-No.2
- bzoj4027: [HEOI2015]兔子与樱花
- 嵌入式软件笔试
- 框架模式 MVC,MVP 在Android中的使用
- combotree按首字母模糊查询