1130: Rectangle Area发表时间:2022-10-27 19:14 1130: Rectangle Area时间限制: 1 Sec 内存限制: 64 MB 题目描述Given diagonal corners of a rectangle with sides parallel to the X and Y axes, compute its area.
输入There will be several cases in the input. Each case will consist of four real numbers on a single line. These numbers represent: X1 Y1 X2 Y2 Where (X1,Y1) and (X2,Y2) are diagonal corners of a rectangle. All four numbers will be in the range from -100.0 to 100.0, with X1 != X2, and Y1 != Y2. No rectangle will have an area smaller than 0.001. End of input is a line with four 0.0’s. 输出Print the area of each rectangle rounded to (and displayed to) 3 decimal places. 样例输入 Copy0 0 3 4 5.2 -4.64 -3.47 2.2 0.0 0.0 0.0 0.0 样例输出 Copy12.000 59.303 #include<bits/stdc++.h> using namespace std; int main(){ double a,b,c,d; while(1){ scanf("%lf%lf%lf%lf",&a,&b,&c,&d); if(a==0&&b==0&&c==0&&d==0) return 0; printf("%.3lf\n",abs((a-c)*(b-d))); } return 0; }
文章分类:
算法例题
|