leetcode 223. Rectangle Area

来源:互联网 发布:局域网文件传输软件 编辑:程序博客网 时间:2024/06/05 16:12
class Solution {public:    int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {        int x1 = max(A,E),x2=min(C,G);        int y2 = min(D,H),y1=max(B,F);        int t1 = 0, t2 = 0;        if(x1 < x2) t1 = x2-x1;        if(y1 < y2) t2 = y2-y1;        return (C-A)*(D-B)+(G-E)*(H-F)-t1*t2;    }};

0 0
原创粉丝点击