main.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <cstdio>
  2. #define Vector Point
  3. using namespace std;
  4. struct Point {
  5. double x;
  6. double y;
  7. Point(double x, double y) : x(x), y(y) {}
  8. bool operator==(const Point &that) const {
  9. return this->x == that.x && this->y == that.y;
  10. }
  11. Point operator-(const Point &that) const {
  12. return Point(this->x - that.x, this->y - that.y);
  13. }
  14. Point operator+(const Point &that) const {
  15. return Point(this->x + that.x, this->y + that.y);
  16. }
  17. };
  18. int main() {
  19. double x11, y11, x12, y12, x21, y21, x22, y22;
  20. while (scanf("%lf%lf%lf%lf", &x11, &y11, &x12, &y12) != EOF) {
  21. scanf("%lf%lf%lf%lf", &x21, &y21, &x22, &y22);
  22. Point p1(x11, y11), p2(x12, y12), p3(x21, y21), p4(x22, y22), p5(0, 0);
  23. if (p1 == p3) {
  24. p5 = p1 + ((p2 - p1) + (p4 - p3));
  25. } else if (p1 == p4) {
  26. p5 = p1 + ((p2 - p1) + (p3 - p4));
  27. } else if (p2 == p3) {
  28. p5 = p2 + ((p1 - p2) + (p4 - p3));
  29. } else {
  30. p5 = p2 + ((p1 - p2) + (p3 - p4));
  31. }
  32. printf("%.3lf %.3lf\n", p5.x, p5.y);
  33. }
  34. return 0;
  35. }