G++要用%f而C++要用%lf
极角排序
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <utility>
using namespace std;
struct P
{
double x, y;
P() {}
P(double x, double y) : x(x), y(y) {}
P operator +(const P &p)
{
return P(x + p.x, y + p.y);
}
P operator -(const P &p)
{
return P(x - p.x, y - p.y);
}
P operator *(const double &d)
{
return P(x * d, y * d);
}
P operator /(const double &d)
{
return P(x / d, y / d);
}
bool operator ==(const P &p)
{
return x == p.x && y == p.y;
}
P operator =(const P &p)
{
x = p.x, y = p.y;
return *this;
}
double det(const P &p)
{
return x * p.y - y * p.x;
}
double dot(const P &p)
{
return x * p.x + y * p.y;
}
};
P in_arr[500];
bool Graham_cmp(P a, P b)
{
P origin(0.0, 0.0);
return (a - origin).det(b - origin) > 0;
}
int main()
{
// freopen("in.in", "r", stdin);
int i = 0;
while(scanf("%lf %lf", &in_arr[i].x, &in_arr[i].y) != EOF)
{
i += 1;
}
sort(in_arr + 1, in_arr + i, Graham_cmp);
for(int j = 0; j < i; ++j) printf("(%.0lf,%.0lf)\n", in_arr[j].x, in_arr[j].y);
return 0;
}