dengxinyi 6 rokov pred
rodič
commit
c29d5a6ea0
1 zmenil súbory, kde vykonal 39 pridanie a 0 odobranie
  1. 39 0
      poj/2624.4th-point/main.cc

+ 39 - 0
poj/2624.4th-point/main.cc

@@ -0,0 +1,39 @@
+#include <cstdio>
+
+#define Vector Point
+
+using namespace std;
+
+struct Point {
+  double x;
+  double y;
+  Point(double x, double y) : x(x), y(y) {}
+  bool operator==(const Point &that) const {
+    return this->x == that.x && this->y == that.y;
+  }
+  Point operator-(const Point &that) const {
+    return Point(this->x - that.x, this->y - that.y);
+  }
+  Point operator+(const Point &that) const {
+    return Point(this->x + that.x, this->y + that.y);
+  }
+};
+
+int main() {
+  double x11, y11, x12, y12, x21, y21, x22, y22;
+  while (scanf("%lf%lf%lf%lf", &x11, &y11, &x12, &y12) != EOF) {
+    scanf("%lf%lf%lf%lf", &x21, &y21, &x22, &y22);
+    Point p1(x11, y11), p2(x12, y12), p3(x21, y21), p4(x22, y22), p5(0, 0);
+    if (p1 == p3) {
+      p5 = p1 + ((p2 - p1) + (p4 - p3));
+    } else if (p1 == p4) {
+      p5 = p1 + ((p2 - p1) + (p3 - p4));
+    } else if (p2 == p3) {
+      p5 = p2 + ((p1 - p2) + (p4 - p3));
+    } else {
+      p5 = p2 + ((p1 - p2) + (p3 - p4));
+    }
+    printf("%.3lf %.3lf\n", p5.x, p5.y);
+  }
+  return 0;
+}