极角排序

//若干个点的极角排序  POJ2007 Scrambled Polygon

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

struct Node{
    int x;
    int y;
};

int cross(Node a,Node b){
    return a.x*b.y-a.y*b.x;
}

int cmp(Node a,Node b){
    if(cross(a,b)>0){
        return 1;
    }
    return 0;
}
Node a[1005];
int main(){
    int n = 0;
    while(~scanf("%d%d",&a[n].x,&a[n].y)){n ++;}
    sort(a + 1,a + n,cmp);
    for(int i = 0;i < n;i ++){
        printf("(%d,%d)
",a[i].x,a[i].y);
    }
    return 0;
}

//一开始sort写的时候写成了  sort(a,a + n,cmp);

//POJ的题不要用 #include<bits/stdc++.h>

原文地址:https://www.cnblogs.com/love-fromAtoZ/p/8991933.html