#include#include #include #include #include using namespace std;#define MAXN 100002struct point { double x,y; point (double x = 0 ,double y = 0){ this->x = x; this->y = y; }};struct line{ point st,en; line(point st,point en){ this->st = st; this->en = en; }};class Isolated{ private: int segNum; vector segments; int ans[MAXN]; int ansNum; public: void init(); void readData(int num); void process(); bool isCross(line la,line lb); bool isInSeg(point a,point la,point lb);//点是否在线段l上 long long dir(point i,point j,point k);//向量叉积};void Isolated::init(){ ansNum = 0; segments.clear();}void Isolated::readData(int num){ segNum = num; double x1,y1,x2,y2; while(num--){ scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2); point st(x1,y1),en(x2,y2); line la(st,en); segments.push_back(la); }}void Isolated::process(){ bool isColl;//线段是否是孤立的 for(int i = 0;i < segNum;i++){ isColl = true; for(int j = segNum - 1;j >= 0;j--){ if(i==j)continue; else{ if(isCross(segments[i],segments[j])){ if(i < j){ //如果和之后落下的相交,那么就被排除 isColl = false; }break; } } } if(isColl) { ans[ansNum++] = i + 1; } } cout<<"Top sticks: "; for(int k = 0; k < ansNum;k++){ if(k < ansNum - 1) cout< <<", "; else cout< <<"."< >cases,cases != 0){ isolated.init(); isolated.readData(cases); isolated.process(); } return 0;}