Time Limit: 2000/1000 MS (java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 127654 Accepted Submission(s): 62250
求实数的绝对值。
Input
输入数据有多组,每组占一行,每行包含一个实数。
Output
对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。
Sample Input
123 -234.00
Sample Output
123.00 234.00
主要考察double类型的输入输出
#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) { double r; while(scanf("%lf",&r)!=EOF) { if(r>0) printf("%.2lf/n",r); else printf("%.2lf/n",-r); } return 0;}新闻热点
疑难解答