zoukankan      html  css  js  c++  java
  • Scrambled Polygon

    题目链接:https://vjudge.net/problem/POJ-2007

    题意:给你一个凸多边形的点,然后再按照极角排序输出那些点。

    思路:直接用差积极角排序。

    #include<bits/stdc++.h>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<vector>
    #include<map>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    const double PI = atan(1.0)*4.;
    const int maxn=200005;
    struct point
    {
        int x,y;
        point friend operator -(point A,point B)
        {
            return {A.x-B.x,A.y-B.y};
        }
    };
    point p[205];
    int chaj(point A,point B)
    {
        return A.x*B.y-A.y*B.x;
    }
    bool cmp(point A,point B)
    {
        return chaj(A-p[1],B-p[1])>0;
    }
    int main()
    {
        int n=1;
        while(~scanf("%d%d",&p[n].x,&p[n].y))
            n++;
        n--;
        sort(p+2,p+n+1,cmp);
        for(int i=1;i<=n;i++)
            printf("(%d,%d)
    ",p[i].x,p[i].y);
    }
  • 相关阅读:
    Lucas 定理
    C语言II博客作业04
    C语言II博客作业03
    C语言II博客作业02
    C语言II博客作业01
    学期总结
    First project
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
  • 原文地址:https://www.cnblogs.com/zcb123456789/p/13782482.html
Copyright © 2011-2022 走看看