dengxinyi 6 jaren geleden
bovenliggende
commit
5c2404e48d
1 gewijzigde bestanden met toevoegingen van 27 en 0 verwijderingen
  1. 27 0
      poj/2007.scrambled-polygon/main.cc

+ 27 - 0
poj/2007.scrambled-polygon/main.cc

@@ -0,0 +1,27 @@
+#include <algorithm>
+#include <cstdio>
+
+using namespace std;
+
+const int N = 50;
+
+struct Vector {
+  int x;
+  int y;
+  Vector(int x = 0, int y = 0) : x(x), y(y) {}
+  int operator^(const Vector &that) const {
+    return this->x * that.y - that.x * this->y;
+  }
+  bool operator<(const Vector &that) const { return 0 < ((*this) ^ that); }
+} vec[N];
+
+int main() {
+  int x, y, n = 0;
+  while (scanf("%d %d", &x, &y) != EOF) {
+    vec[n].x = x;
+    vec[n++].y = y;
+  }
+  sort(vec + 1, vec + n);
+  for (int i = 0; i < n; i++) printf("(%d,%d)\n", vec[i].x, vec[i].y);
+  return 0;
+}