把交叉点的坐标求出来即可。

#define max(a,b)  ( (a)>(b)?(a):(b) )
#define min(a,b) ( (a)<(b)?(a):(b) )
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int downx,downy,upx,upy;
int crossArea;
int all;
downx=max(A,E);
downy=max(B,F);
upx =min(C,G);
upy =min(D,H);
if(downx>upx||downy>upy)crossArea=0;
else crossArea=(upx-downx)*(upy-downy);
all=(C-A)*(D-B)+(G-E)*(H-F);
return all-crossArea;
}

  

Rectangle Area || LeetCode的更多相关文章

  1. Rectangle Area——LeetCode

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

  2. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

  3. [LeetCode] 850. Rectangle Area II 矩形面积之二

    We are given a list of (axis-aligned) rectangles.  Each rectangle[i] = [x1, y1, x2, y2] , where (x1, ...

  4. [LeetCode] 223. Rectangle Area 矩形面积

    Find the total area covered by two rectilinearrectangles in a 2D plane. Each rectangle is defined by ...

  5. LeetCode 223. 矩形面积(Rectangle Area)

    223. 矩形面积 223. Rectangle Area 题目描述 在二维平面上计算出两个由直线构成的矩形重叠后形成的总面积. 每个矩形由其左下顶点和右上顶点坐标表示,如图所示. LeetCode2 ...

  6. [leetcode] Rectangle Area

    Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...

  7. 【leetcode】Contains Duplicate & Rectangle Area(easy)

    Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your funct ...

  8. 【刷题-LeetCode】223. Rectangle Area

    Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...

  9. leetcode之Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

随机推荐

  1. js点击a链接弹出alert对话框

    代码 <html> <head> <meta charset="utf-8"> <meta name="generator&qu ...

  2. Java类加载

    类的生命周期是: 在一个类编译完成之后,下一步就需要开始使用类,如果要使用一个类,肯定离不开JVM.在程序执行中JVM通过装载,链接,初始化这3个步骤完成. 类的装载是通过类加载器完成的,加载器将.c ...

  3. 每天一个linux命令--locate

    linux下,不知道自己安装的程序放在哪里了,可以使用locate命令进行查找. [hongye@dev107 ~]$ locate activemq.xml /home/hongye/hongyeC ...

  4. Shell 编程基础之 While 练习

    一.语法 while [ condition ] # 当 condition 条件成立时,就进行循环,直到条件不成立停止 do #执行内容 done 二.练习 输入用户输入的参数,直到用户输入 &qu ...

  5. C#解决从含身份证号码的Excel表格导入数据库的问题

    用C#做从Excel表导入SQL数据库时发现从EXCEL导入的身份证号码会变成科学表示方法. 解决这个问题是比较容易的,首先,打开电子表格,选中“身份证号码”一列,右键选择“设置单元格格式”,进入单元 ...

  6. ViewState与Session

    在asp时代, 大家都知道一个html控件的值,比如input 控件值,当我们把表单提交到服务器后, 页面再刷新回来的时候, input里面的数据已经被清空. 这是因为web的无状态性导致的, 服务端 ...

  7. CF#335 Lazy Student

    Lazy Student time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  8. 利用mysqldump 将一个表按条件导出数据

    mysqldump -uroot -pdsideal -t dsideal_db t_resource_info --where="res_type=1 and group_id=1 and ...

  9. Codeforces Round #209 (Div. 2) A. Table

    #include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...

  10. 《DON'T MAKE ME THINK》/《点石成金访客至上的网页设计秘笈》 读书笔记

    1.web页面要尽可能简单,让用户不用思考就能知道页面的功能,如果要进行一些崭新的.开拓性的或者非常复杂的页面设计时, 此时要利用页面元素的外观.精心选择的名称.页面布局以及少量仔细斟酌过的文字,使页 ...