UVa 10250 - The Other Two Trees
来源:互联网 发布:相约星期六网络直播 编辑:程序博客网 时间:2024/05/17 07:31
题目:已知2点,求另外两点,使得这4个点构成正方形。
分析:计算几何。直接求出已知线段的长度相同的垂直平分线即可。求中点,利用向量计算点坐标。
说明:注意精度。
#include <iostream>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;typedef struct pnode{double x,y;}point;point A,B,C,D,M;double dist( point a, point b ){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){while ( ~scanf("%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y) ) {M.x = (A.x+B.x)*0.5;M.y = (A.y+B.y)*0.5;double l = dist( A, B );double sinA = (B.y-A.y)/l;double cosA = (B.x-A.x)/l;C.x = M.x - 0.5*l * sinA;C.y = M.y + 0.5*l * cosA;D.x = M.x + 0.5*l * sinA;D.y = M.y - 0.5*l * cosA;printf("%.10lf %.10lf %.10lf %.10lf\n",C.x,C.y,D.x,D.y);}return 0;}
0 0
- uva 10250 - The Other Two Trees
- uva-10250-The Other Two Trees
- Uva 10250 - The Other Two Trees
- uva 10250 - The Other Two Trees
- uva 10250 - The Other Two Trees
- UVA 10250 The Other Two Trees
- uva 10250 - The Other Two Trees
- UVa 10250 - The Other Two Trees
- UVa 10250 - The Other Two Trees
- UVa 10250 The Other Two Trees
- UVa 10250 - The Other Two Trees
- UVA 10250 The Other Two Trees
- UVA - 10250 The Other Two Trees
- UVA 10250 The Other Two Trees
- UVA - 10250 The Other Two Trees
- UVA - 10250 The Other Two Trees
- UVA 10250-The Other Two Trees
- UVA-10250 The Other Two Trees
- 高并发高流量网站架构(转)
- 在非XXX.aspx.cs文件中使用Response、Request对象
- linux init.d
- 骚年你是怎么了
- 【网络协议】TCP的流量控制机制
- UVa 10250 - The Other Two Trees
- Android2.3及Linux2.6.29内核模拟器版本编译与调试
- C# 多语言资源文件的访问
- HTML实体与网页编码
- objective-c 的一些基础知识整理
- 骚年肿么了你?
- 安卓 文字环绕图片
- 添加tslib到directfb
- 在页面中调用skype