题意:给你平行四边形两条边的顶点,让你求第四个点。

思路:要找到俩边的公共点,然后向量运算。

AC代码:

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const double eps = 1e-8;
int sgn(double x)
{if(fabs(x) < eps) return 0;else return x < 0 ? -1 : 1;
}
struct Point{double x, y;Point(){}Point(double _x, double _y){x = _x, y = _y;}bool operator == (Point b) const{return sgn(x - b.x) == 0 && sgn(y - b.y) == 0;}bool operator < (Point b)const{return sgn(x - b.x) == 0 ? sgn(y - b.y < 0) : x < b.x;}Point operator - (const Point &b)const{return Point(x - b.x, y - b.y);}//叉积double operator ^(const Point &b){return x * b.y - y * b.x;}//点积double operator *(const Point &b){return x * b.x + y * b.y;}double len(){return hypot(x, y);}double len2(){return x * x + y * y;}double distant(Point p){return hypot(x - p.x, y - p.y);}Point operator + (const Point &b)const{return Point (x + b.x, y + b.y);}Point operator * (const double &k)const{return Point(x * k, y * k);}Point operator / (const double &k)const{return Point(x / k, y / k);}
};
int main()
{double x1, x2, x3, x4, y1, y2, y3, y4;Point p[4], c;while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)){p[0] = Point(x1,y1);p[1] = Point(x2,y2);p[2] = Point(x3,y3);p[3] = Point(x4,y4);sort(p , p + 4);if(p[0] == p[1]){c = p[2] + p[3] - p[1];}if(p[1] == p[2]){c = p[0] + p[3] - p[1];}if(p[2] == p[3]){c = p[1] + p[0] - p[3];}printf("%.3f %.3f\n",c.x, c.y);}return 0;
}

转载于:https://www.cnblogs.com/Carered/p/11406700.html

UVA 10242 Fourth Point相关推荐

  1. UVA 10242 || Fourth Point !!(求平行四边形第四点

    给第一条边的两个端点,第二条边的两个端点,求平行四边形的第四个点. 给了 四个点,不一定按照 起点终点的顺序,调整一下就好了..  A  B  B C 的顺序 #include<iostream ...

  2. UVa 207 - PGA Tour Prize Money

    时间限制:3.000秒 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&catego ...

  3. Fourth Point !!

    链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  4. [搜索]UVa 129 困难的串

    题意:将一个包含两个相邻的重复子串的子串,称为"容易的串",其他为"困难的串". 输入正整数n和l,输出由前l个字符组成的,字典序第n小的困难的串. 输入样例: ...

  5. uva 401.Palindromes

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  6. Uva 3767 Dynamic len(set(a[L:R])) 树套树

    Dynamic len(set(a[L:R])) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 https://uva.onlinejudge.org/in ...

  7. UVA 11752 超级幂

    UVA 11752 超级幂 Z - The Super Powers Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & ...

  8. UVa 11174 - Stand in a Line

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  9. UVa 10112 - Myacm Triangles

    UVa第一卷最后一题. 求内部不含点并且面积最大的三角形. 暴力. 代码如下: 1 #include<iostream> 2 #include<cstdio> 3 #inclu ...

最新文章

  1. 自然语言处理NLP基本知识小结
  2. c#资源管理器【转】
  3. 音频在计算机中的存储
  4. python教程:可变长参数(*args、**kwargs)、返回值(return)
  5. 汇编学习笔记(3)-80x86指令集
  6. 英特尔第十代处理器为什么不支持win7_5GHz动力澎湃 高主频多核处理器成就巅峰玩家...
  7. ASP.NET判断是否为手机登录
  8. GO_00:Mac之Item2的配置安装
  9. ETC因背胶问题脱落,如何重新激活?
  10. james邮件服务器的用户信息添加
  11. Atitit office Ooxml excel标准的主要内容 目录 1.1. 物理存储 zip+文件夹包+xml 1 1.2. Package Structure 1 1.3. 内容部分 1
  12. java ajax 读取流_javascript-如何使用AJAX读取实时流数据
  13. 土拍熔断意味着什么_熔断意味着什么
  14. 【转】CAN总线与CANOPEN协议入门
  15. 企业建站选择阿里云服务器配置详细教程
  16. 手机芯片研发有多难_手机芯片设计很简单?详解手机芯片设计的难点
  17. k8s集群二进制部署 1.17.3
  18. 怎么看计算机配件型号,如何看硬件参数
  19. MySQL DELETE 操作后没有释放磁盘空间
  20. DTVideo UE录屏插件使用说明

热门文章

  1. 蓝湖类似的软件_一款产品设计团队必备的协作工具——蓝湖
  2. 量化投资工具-AKShare是如何进行投资交易的?
  3. 解决listview 超出界面问题
  4. android开发 Activity包含Fragment切换背景黑色闪屏解决方案
  5. 阿翔编程学-WebService介绍及使用
  6. 在Word2010中给首字设置下沉
  7. linux机器上crontab定时任务将日志输出到以日期命名的log文件
  8. springboot毕设项目影评网站系统4i684(java+VUE+Mybatis+Maven+Mysql)
  9. 流量明星不灵了,与ta糊不糊无瓜。
  10. 工大助手电费查询接口讲解