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

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

AC代码:

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const double eps = 1e-;
int sgn(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
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) == && sgn(y - b.y) == ;
}
bool operator < (Point b)const{
return sgn(x - b.x) == ? sgn(y - b.y < ) : 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[], c;
while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4))
{
p[] = Point(x1,y1);
p[] = Point(x2,y2);
p[] = Point(x3,y3);
p[] = Point(x4,y4);
sort(p , p + );
if(p[] == p[])
{
c = p[] + p[] - p[];
}
if(p[] == p[])
{
c = p[] + p[] - p[];
}
if(p[] == p[])
{
c = p[] + p[] - p[];
}
printf("%.3f %.3f\n",c.x, c.y);
}
return ;
}

最新文章

  1. A couple of notes about .NET Framework 4.6 setup behaviors
  2. DX 系列之 ComboBoxEdit
  3. CSS3--overflow属性
  4. Echarts 地图(map)插件之 鼠标HOVER和tooltip自定义提示框
  5. libavcodec/dxva2.h:40:5: error: unknown type name &#39;IDirectXVideoDecoder&#39;
  6. UI进阶 多线程
  7. think straight系列读书笔记之《暗时间》
  8. bounds的深入研究
  9. 50道java线程面试题
  10. XML 从基础到精通
  11. address2line 定位 Android c++奔溃位置
  12. textarea高度随内容自适应
  13. idea 导eclipse项目
  14. var、let、const区别
  15. IDEA中debug启动tomcat报错。Error running t8:Unable to open debugger port(127.0.0.1:49225):java.net.BindException&quot;Address alread in use:JVM_Bind&quot;
  16. 初学spring boot 一
  17. Redis(2)---数据持久化
  18. oracle 之 基础操作
  19. Patterns for Asynchronous MVVM Applications: Commands
  20. seleniumWebdriver浏览器驱动信息汇总

热门文章

  1. HTML5: HTML5 Web 存储
  2. PHP-文件和目录操作
  3. 32. 持续集成简介及JDK、Tomcat、Jenkins环境搭建
  4. C++异常处理try、catch 没有finally
  5. .net报错大全
  6. ajax 通过回调函数获取异步数据
  7. activiti7从act_ge_bytearray表中查询资源文件并保存到桌面文件夹中
  8. MOV EAX,DWORD PTR SS:[EBP+8]
  9. Arcpy 遍历每一个要素新建要素类
  10. Failed! Error: Unknown error 1130