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

#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. BZOJ4684 : Company Organization

    二分答案,转化为判定问题. 建立有向图,$a->b$连边表示$a$是$b$的子集,至此可以处理掉$1$和$2$. 对于$5$,则往对应点的集合塞一个元素,即可满足$5$. 首先求出强连通分量进行 ...

  2. 洛谷 P1111 修复公路 Label:并查集

    题目背景 A地区在地震过后,连接所有村庄的公路都造成了损坏而无法通车.政府派人修复这些公路. 题目描述 给出A地区的村庄数N,和公路数M,公路是双向的.并告诉你每条公路的连着哪两个村庄,并告诉你什么时 ...

  3. TYVJ P3407 佳佳的魔法照片 Label:语文很重要 语文很重要 语文很重要

    描述 佳佳的魔法照片(mphoto.pas\c\cpp) [题目背景] 佳佳的魔法照片(Magic Photo):如果你看过<哈利•波特>,你就会知道魔法世界里的照片是很神奇的.也许是因为 ...

  4. HDU-统计难题

    DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Inp ...

  5. package XXX.i386.rpm is not installed(检查在Linux上安装Oracle所需的pkg时)

    如下转自一个论坛,忘了哪了,一直在电脑上存的. I've got Oracle Enterprise Linux 5 to install an Oracle server. Checking req ...

  6. JS:原型

      function Box(){ } //使用字面量的方式创建原型对象,这里{}就是对象,是Object, new Object相当于{} Box.prototype = { name:" ...

  7. 透过现象看现象(SQL501N错误处理)

    某日一直运行比较正常的报表系统,突然报存储过程执行失败,查看DB2 错误返回码为sql501n,查看此错误原因如下: [db2inst1@limt ~]$ db2 ? sql501n SQL0501N ...

  8. spring源码学习之路---AOP初探(六)

    作者:zuoxiaolong8810(左潇龙),转载请注明出处,特别说明:本博文来自博主原博客,为保证新博客中博文的完整性,特复制到此留存,如需转载请注明新博客地址即可. 最近工作很忙,但当初打算学习 ...

  9. 六、雪花《苹果iOS实例编程入门教程》

    该app为应用的功能为制作一场雪景 现版本 SDK 8.4 Xcode 纲要:- UIImageView 的运用- onTimer 代码运用- onAnimation 代码运用 运行Xcode 选择 ...

  10. [LintCode] Identical Binary Tree 相同二叉树

    Check if two binary trees are identical. Identical means the two binary trees have the same structur ...