• POJ 2007 Scrambled Polygon


    虽然A了但是完全不懂这题在干什么。

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define maxn 105
    using namespace std;
    struct point
    {
        int x,y;
        point (int x,int y):x(x),y(y) {}
        point () {}
        friend point operator - (point x,point y)
        {
            return point(x.x-y.x,x.y-y.y);
        }
        friend int operator * (point x,point y)
        {
            return x.x*y.y-x.y*y.x;
        }
    }p[maxn];
    int ps,qs,tot=0,top=0,stack[maxn];
    bool vis[maxn];
    bool cmp1(point x,point y)
    {
        if (x.y!=y.y) return x.y<y.y;
        return x.x<y.x;
    }
    bool cmp2(point x,point y)
    {
        return (x-p[1])*(y-p[1])>=0;
    }
    int main()
    {
        while (scanf("%d%d",&ps,&qs)!=EOF)
            p[++tot]=point(ps,qs);
        sort(p+2,p+tot+1,cmp2);
        int ret=-1;
        for (int i=1;i<=tot;i++) if ((!p[i].x) && (!p[i].y)) {ret=i;break;}
        printf("(0,0)
    ");
        for (int i=ret+1;i!=ret;i=i%tot+1)
            printf("(%d,%d)
    ",p[i].x,p[i].y);
        return 0;
    }
  • 相关阅读:
    audio_policy.conf说明(翻译)
    Qt
    linux C
    Linux C
    Linux C
    Qt
    Qt
    JSON
    JSON
    Qt
  • 原文地址:https://www.cnblogs.com/ziliuziliu/p/6322092.html
Copyright © 2020-2023  润新知