杭电ACM2003--求绝对值

求绝对值

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 182869    Accepted Submission(s): 88463


Problem Description
求实数的绝对值。
 
Input
输入数据有多组,每组占一行,每行包含一个实数。
 
Output
对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。
 
Sample Input
123 -234.00
 
Sample Output
123.00 234.00
 
短小精悍精神体现在最简单水题···
试过用绝对值函数来写会超时
1 #include<stdio.h>
2 int main()
3 {
4     double n;
5     while(~scanf("%lf",&n))
6         printf("%.2f
",(n>0)?n:-n);
7     return 0;
8 }
原文地址:https://www.cnblogs.com/lightice/p/10261074.html