uva 10250(数学)

来源:互联网 发布:python读音 编辑:程序博客网 时间:2024/06/06 09:38

题解:已知一个正方形的相对的顶点的坐标,求其他两个点的坐标。相对的点的中点是同一个点,所以计算出中点坐标带入,得到公式计算。

#include <stdio.h>#include <math.h>int main() {double x1, x2, y1, y2;while (scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != EOF) {double x3 = (x1 + x2 + y2 - y1) / 2;double y3 = (y1 + y2 + x1 - x2) / 2;double x4 = (x1 + x2 - y2 + y1) / 2;double y4 = (y1 + y2 - x1 + x2) / 2;printf("%.10lf %.10lf %.10lf %.10lf\n", x3, y3, x4, y4);}return 0;}


0 0