UVA 10250 The Other Two Trees

#include <cstdio>
#include <cmath>

int main() {
	double x1, y1, x2, y2;
	double x3, y3, x4, y4;
	double a, b;
	while (scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != EOF) {
		if (fabs(x1 - x2) < 1e-8 && fabs(y1 - y2) < 1e-8) {
			printf("Impossible.\n");
			continue;
		}
		a = (y1 - y2 + (x2 - x1)) / 2; 
		b = (y1 - y2 - (x2 - x1)) / 2;
		x3 = x1 + a;
		x4 = x1 - b;
		y3 = y1 - b;
		y4 = y1 - a;
		printf("%.10lf %.10lf %.10lf %.10lf\n", x3, y3, x4, y4);
	}


	return 0;
}

你可能感兴趣的:(UVA 10250 The Other Two Trees)