Given two rectangles and the coordinates of two points on the diagonals of each rectangle,you have to calculate the area of the intersected part of two rectangles. its sides are parallel to OX and OY .

Input

The first line of input is 8 positive numbers which indicate the coordinates of four points that must be on each diagonal.The 8 numbers are x1,y1,x2,y2,x3,y3,x4,y4.That means the two points on the first rectangle are(x1,y1),(x2,y2);the other two points on the second rectangle are (x3,y3),(x4,y4).

Output

For each case output the area of their intersected part in a single line.accurate up to 2 decimal places.

Sample Input

1.00 1.00 3.00 3.00 2.00 2.00 4.00 4.00
5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50

Sample Output

1.00
56.25 // 没考虑无相交区域
 #include<stdio.h>
int main()
{
double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
{
if(x1>x2)
{ t=x2; x2=x1; x1=t; }
if(y1>y2)
{ t=y2; y2=y1; y1=t; }
if(x3>x4)
{ t=x4; x4=x3; x3=t; }
if(y3>y4)
{ t=y4; y4=y3; y3=t; }
a=x1-x4>x3-x2?x1-x4:x3-x2;
b=y1-y4>y3-y2?y1-y4:y3-y2;
printf("%.2f\n", a*b);
}
return ;
}

WA

// 还是错得离谱 感觉没有智商T^T
 #include<stdio.h>
int main()
{
double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
{
if(x1>x2)
{ t=x2; x2=x1; x1=t; }
if(y1>y2)
{ t=y2; y2=y1; y1=t; }
if(x3>x4)
{ t=x4; x4=x3; x3=t; }
if(y3>y4)
{ t=y4; y4=y3; y3=t; }
a=x1-x4>x3-x2?x1-x4:x3-x2;
b=y1-y4>y3-y2?y1-y4:y3-y2;
if(a>=||b>=) printf("0.00\n");
else printf("%.2f\n", a*b);
}
return ;
}

WA*2

// 
 #include<stdio.h>
int main()
{
double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
{
if(x1>x2)
{ t=x2; x2=x1; x1=t; }
if(y1>y2)
{ t=y2; y2=y1; y1=t; }
if(x3>x4)
{ t=x4; x4=x3; x3=t; }
if(y3>y4)
{ t=y4; y4=y3; y3=t; }
a=(x2<x4?x2:x4)-(x1>x3?x1:x3);
b=(y2<y4?y2:y4)-(y1>y3?y1:y3);
if(a<||b<) printf("0.00\n");
else printf("%.2f\n", a*b);
}
return ;
}

AC

5D - Rectangles的更多相关文章

  1. 三维模型2.5D轮廓提取及遮挡部分的剔除

    轮廓提取相对容易,只需在2.5D渲染视角下,导出模型的顶点坐标以及基于视角的消隐后的三角形面,将三角面投影后合并就可得到轮廓,轮廓坐标基于2.5d图的基准坐标换算就得到.提取轮廓的在我另外一篇文章中有 ...

  2. 3dmax渲染插件,生成2.5d瓦片

    基于3dmax2013的2.5d渲染插件,demo版,需要的和感兴趣的可以试用,这是百度网盘地址:http://pan.baidu.com/s/1c0mYY7e 插件主要功能,按层级对3dmax场景进 ...

  3. poj-1314 Finding Rectangles

    题目地址: http://poj.org/problem?id=1314 题意: 给出一串的点,有些点可以构成正方形,请按照字符排序输出. 因为这道题的用处很大, 最近接触的cv 中的Rectangl ...

  4. [ACM_暴力][ACM_几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)

    Description We are given a figure consisting of only horizontal and vertical line segments. Our goal ...

  5. 该如何认识ZBrush中的2.5D绘画

    ZBrush不仅对3D行业进行了改革.让艺术家感到无约束自由创作的3D设计,同时它还是一个强大的绘画程序!基于强大的Pixol功能,ZBrush®将数字绘画提升到一个新的层次.如下图所示,插画功能主要 ...

  6. codeforces 713B B. Searching Rectangles(二分)

    题目链接: B. Searching Rectangles time limit per test 1 second memory limit per test 256 megabytes input ...

  7. White Rectangles[HDU1510]

    White Rectangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. Java基础之在窗口中绘图——绘制直线和矩形(Sketcher 2 drawing lines and rectangles)

    控制台程序. import javax.swing.JComponent; import java.util.*; import java.awt.*; import java.awt.geom.*; ...

  9. Counting Rectangles

    Counting Rectangles Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1043 Accepted: 546 De ...

随机推荐

  1. 30.SSH配置文件模板和类库.md

    目录 1.struts2 4.类库 1.struts2 1.<?xml version="1.0" encoding="UTF-8"?>2.< ...

  2. Hibernate学习笔记2.1(Hibernate基础配置)

    Hibernate基础配置 1.<property name="hbm2ddl.auto">update</property> 在SessionFactor ...

  3. ArcMap导入图层出现General function failure问题 [转]

      ArcMap导入图层出现General function failure问题 [转] Link: http://www.cnblogs.com/angelx/p/3391967.html 问题描述 ...

  4. swift重写导航控制器类的 initialize 方法

    //这个方法,是当这个类第一次被创建时调用,且只调用一次 override class func initialize() { let navBar = UINavigationBar.appeara ...

  5. spring 中AOP的基本知识点

    首先AOP就是一个动态代理,主要运用在事务控制,日志记录,安全控制等方面 1.连接点(Joinpoint):一个连接点 总是 代表一个方法的执行. 2.切入点(Pointcut):匹配连接点的 表达式 ...

  6. servlet中的执行顺序

  7. 'Could not find first log file name in binary log index file'的解决办法

    数据库主从出错: Slave_IO_Running: No 一方面原因是因为网络通信的问题也有可能是日志读取错误的问题.以下是日志出错问题的解决方案: Last_IO_Error: Got fatal ...

  8. 弹窗切换page进行关闭

    beforeRouteLeave(to,from,next){ //这里写关闭弹窗 // 这里跳转路由 MessageBox.close(); next() // next()别漏,不然不跳转 }

  9. 七个不可错过的React组件库与开发框架

    React是如今最火爆的前端技术,而React最棒的一个特点就是有大量功能丰富的组件库和开发框架可用.从按钮到卷轴到工具条,应有尽有,而且这些组件可以各行其是,也可以组装成复杂的UI,你也可以把UI分 ...

  10. ATM--代码

    //信1705-2 张小军 20173662 import java.io.*; import java.util.ArrayList; import java.util.Scanner;public ...