标签:
题目描述:public class Solution { public int ComputeArea(int A, int B, int C, int D, int E, int F, int G, int H) { var sq1 = Math.Abs(A-C) * Math.Abs(B-D); var sq2 = Math.Abs(E-G) * Math.Abs(F-H); int common = 0; if(D<=F || C<=E || G <=A || H <=B){ common = 0; } else{ var xArr = new int[]{A,E,C,G}.OrderBy(x=>x).ToList(); var yArr = new int[]{B,F,D,H}.OrderBy(y=>y).ToList(); common = Math.Abs(xArr[1] - xArr[2]) * Math.Abs(yArr[1] - yArr[2]); } return sq1 + sq2 - common; } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/lan_liang/article/details/49188467