主要是利用了数学中的叉乘运算,学好数学还是很重要啊,都是泪

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

struct node
{
    double x, y;
};
struct line
{
    node s, e;
}p[100100];
bool ya[100100];

bool paichi(line a, line b) //排斥判断,最大值必须大于最小值,否则必无交点
{
    if(max(a.s.x, a.e.x) >= min(b.s.x, b.e.x) && max(a.s.y, a.e.y) >= min(b.s.y, b.e.y)
       && max(b.s.x, b.e.x) >= min(a.s.x, a.e.x) && max(b.s.y, b.e.y) >= min(a.s.y, a.e.y))
        return true;
    else return false;
}
double cross(node a, node b, node c)
{
    double x1 = b.x - a.x, y1 = b.y - a.y;
    double x2 = c.x - a.x, y2 = c.y - a.y;
    return x1 * y2 - x2 * y1;
}

bool kuali(line a, line b) //跨立判断
{
    if(cross(a.s, a.e, b.s) * cross(a.s, a.e, b.e) <= 0 && cross(b.s, b.e, a.s) * cross(b.s, b.e, a.e) <= 0)
        return true;
    else return false;
}

int main()
{
    int n;

    while(scanf("%d", &n), n)
    {
        memset(ya, false, sizeof ya);
        for(int i = 1; i <= n; i++)
            scanf("%lf%lf%lf%lf", &p[i].s.x, &p[i].s.y, &p[i].e.x, &p[i].e.y);

        int res = n;
        for(int i = 1; i <= n; i++)
        {
            for(int j = i + 1; j <= n; j++)
                if(paichi(p[i], p[j]) == true)
                    if(kuali(p[i], p[j]) == true)
                    {
                        ya[i] = true;
                        res--;
                        break;
                    }
        }

        printf("Top sticks:");
        for(int i = 1; i <= n; i++)
        {
            if(ya[i] == false && res == 1)
            {
                printf(" %d.", i);
                res--;
            }
            else if(ya[i] == false && res != 1)
            {
                printf(" %d,", i);
                res--;
            }
        }
        printf("\n");
    }

    return 0;
}