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;}新聞熱點
疑難解答