Rectangle Area || LeetCode
把交叉点的坐标求出来即可。
#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的更多相关文章
- Rectangle Area——LeetCode
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
- [LeetCode] Rectangle Area 矩形面积
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...
- [LeetCode] 850. Rectangle Area II 矩形面积之二
We are given a list of (axis-aligned) rectangles. Each rectangle[i] = [x1, y1, x2, y2] , where (x1, ...
- [LeetCode] 223. Rectangle Area 矩形面积
Find the total area covered by two rectilinearrectangles in a 2D plane. Each rectangle is defined by ...
- LeetCode 223. 矩形面积(Rectangle Area)
223. 矩形面积 223. Rectangle Area 题目描述 在二维平面上计算出两个由直线构成的矩形重叠后形成的总面积. 每个矩形由其左下顶点和右上顶点坐标表示,如图所示. LeetCode2 ...
- [leetcode] Rectangle Area
Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...
- 【leetcode】Contains Duplicate & Rectangle Area(easy)
Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your funct ...
- 【刷题-LeetCode】223. Rectangle Area
Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...
- leetcode之Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
随机推荐
- WPF之依赖属性
Introduction When you begin to develop appliations with WPF, you will soon stumble across Dependency ...
- ural 1144. The Emperor's Riddle
1144. The Emperor's Riddle Time limit: 1.0 secondMemory limit: 4 MB Background In the olden times th ...
- 【POJ2096】Collecting Bugs 期望
[POJ2096]Collecting Bugs Description Ivan is fond of collecting. Unlike other people who collect pos ...
- 串 & 容斥原理
题意: 给出n (n<=50000) 个长度为4的字符串,问有且仅有d(1<=d<=4)处不相同的字符串有几对. SOL: 一直对着4发呆,这么小的字符串背后有什么玄学呢= =... ...
- Android 情景模式设置
情景模式的设置大家应当相当熟悉了,但是在Android中如何通过自己的程序进行情景模式的设置呢,情景模式分为多种多种,即可以使用系统自带的,也可 以使用自定义的,但是在开发某些程序时,可能需要在程序中 ...
- jq对象转为dom对象:$(".div1")[0] dom对象转为jq对象:$(dom对象)
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- [深入浅出Windows 10]实现饼图控件
13.2 实现饼图控件 上一小节讲解了动态生成折线图和区域图,对于简单的图形这样通过C#代码来生成的方式是很方便的,但是当我们的图表要实现更加复杂的逻辑的时候,这种动态生成的方式就显得力不从心了,那就 ...
- 【搬运工】NOIP吧置顶贴
目的是存置顶贴里的链接.. 原帖:http://tieba.baidu.com/p/1753284199 资源站:*C++资源:http://tieba.baidu.com/p/1239792581* ...
- 【BZOJ1088】[SCOI2005]扫雷Mine 递推
调LCT奔溃,刷水调节一下. #include <iostream> #include <cstdio> #include <cstring> using name ...
- linux下常用关机命令
linux下常用的关机命令有:shutdown.halt.poweroff.init:重启命令有:reboot.下面本文就主要介绍一些常用的关机命令以及各种关机命令之间的区别和具体用法. 首先来看一下 ...