判断两个矩阵是否相交
//Write a function to check if two rectangles defined as below, have common area or not. The functions take the top left and bottom right coordinate as input and return 1 if they have common area, otherwise return 0. struct Point { int x; int y; }; struct Rec { Point l_top; Point r_bot; }; bool CheckHasCommenRange(Rec& rec_a, Rec& rec_b) { if (rec_a.l_top.x > rec_b.l_top.x) swap(rec_a, rec_b); if (rec_b.l_top.x >= rec_a.r_bot.x) return false; if (rec_a.r_bot.y > rec_b.r_bot.y) swap(rec_a, rec_b); if (rec_b.r_bot.y >= rec_a.r_bot.y) return false; return true; }
Passion, patience, perseverance, keep it and move on.

浙公网安备 33010602011771号