Datahub
数据改变生活

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.

样例输入 Copy

0 0 3 4

5.2 -4.64 -3.47 2.2

0.0 0.0 0.0 0.0

样例输出 Copy

12.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;

}


文章分类: 算法例题
分享到:
QQ:258506508                                     联系电话:020-000000    000-000000                                   联系邮箱:xxx@.co.m                                     联系地址:XXX省XXX市XXX县XXX路