判断矩形重叠
//矩形结构 struct Rect{ int leftTopX;//左上角横坐标 int leftTopY;//左上角纵坐标 int rightBottomX;//右下角横坐标 int rightBottomY;//右下角纵坐标 }; bool CrossLine(const Rect &r1, const Rect &r2) { return abs((r1.leftTopX + r1.rightBottomX) - (r2.leftTopX + r2.rightBottomX)) < (abs(r1.rightBottomX + r2.rightBottomX - r1.leftTopX - r2.leftTopX)) && abs((r1.leftTopY + r1.rightBottomY) - (r2.leftTopY + r2.rightBottomY)) < (abs(r1.rightBottomY + r2.rightBottomY - r1.leftTopY - r2.leftTopY)); }