杭电 2056 Rectangles
2014-02-06 17:44
127 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2056
(1)对于double的输入必须是lf,输出没有要求;
(2)交换两个数的值是用变量来交换,不是指针;
(3)横坐标小,纵坐标不一定小(错误认为交换横坐标就一定交换其纵坐标)。
#include<stdio.h> void swap(double *x,double *y){ double t; t = *x; *x = *y; *y = t; } int main() { double x1,x2,x3,x4,y1,y2,y3,y4,x5,y5,x6,y6; while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4) != EOF)//必须有l { if(x1>x2)swap(&x1,&x2); if(y1>y2)swap(&y1,&y2); if(x3>x4)swap(&x3,&x4); if(y3>y4)swap(&y3,&y4); x5 = x1>x3?x1:x3; y5 = y1>y3?y1:y3; x6 = x2>x4?x4:x2; y6 = y2>y4?y4:y2; //printf("%.2lf\n",x6 >= x5 && y6 >= y5?(x6-x5)*(y6-y5):0); if(x6 > x5 && y6 > y5) printf("%.2f\n",(x6-x5)*(y6-y5)); else printf("0.00\n"); } return 0; }
(1)对于double的输入必须是lf,输出没有要求;
(2)交换两个数的值是用变量来交换,不是指针;
(3)横坐标小,纵坐标不一定小(错误认为交换横坐标就一定交换其纵坐标)。
相关文章推荐
- 杭电ACM 2056 Rectangles
- 杭电2056Rectangles(未解决)
- 杭电2056之Rectangles 杭电
- 杭电2056、Rectangles
- 杭电2056Rectangles
- 杭电2056 Rectangles
- HDU 2056 Rectangles
- HDU 2056 Rectangles (求两个相交矩形面积)
- HDOJ-2056(Rectangles)
- HDU 2056 Rectangles(计算相交面积)
- HDU-2056-Rectangles
- 【暑期基础3】D HDU 2056 Rectangles (几何)
- HDOJ2056_Rectangles
- hdoj.2056 Rectangles 20140729
- HDOJ 2056 Rectangles
- HDU ACM 11 2056 Rectangles
- 杭电2056
- hdoj-2056-Rectangles
- 2056 Rectangles
- HDU——2056——Rectangles