题目链接:http://poj.org/problem?id=1673

AC代码:

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const double eps = 1e-;
const double pi = acos(-1.0);
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);
}
Point rotate(Point p, double angle){
Point v = (*this) - p;
double c = cos(angle), s = sin(angle);
return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
}
};
Point GetLineIntersection(Point P, Point v, Point Q, Point w){
Point u = P - Q;
double t =(w^u)/(v^w);
return P + v*t;
}
int main()
{
Point A, B, C;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%lf %lf %lf %lf %lf %lf",&A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
Point v = B,u = C;
v = v.rotate(A, pi / 2.0), u = u.rotate(B, pi / 2.0);
Point c = GetLineIntersection(C, v - A, A, u - B);
printf("%.4f %.4f\n",c.x + eps, c.y + eps);
}
return ;
}

最新文章

  1. UML类图(上):类、继承和实现
  2. centos7 编译php56
  3. T138
  4. 从全局中通过class类名获取标签
  5. Python快速建站系列-Part.Five.1-个人主页及发表文章
  6. XCode打包脚本
  7. Ibatis中传List参数
  8. 多校5 HDU5787 K-wolf Number 数位DP
  9. UVA 315 315 - Network(求割点个数)
  10. 第一个php网页
  11. ORACLE模拟临时文件、日志成员、口令文件丢失情况与恢复【weber出品】
  12. bat脚本命令
  13. js面试题-2
  14. android 高仿京东
  15. 【Netty】(4)—源码AbstractBootstrap
  16. prometheus + grafana + node_exporter + alertmanager 的安装部署与邮件报警 (一)
  17. warmpserver 配置别人能访问自己的项目地址
  18. Eclipse 中构建 Maven 项目的完整过程 - 动态 Web 项目
  19. C# 数据推送 实时数据推送 轻量级消息订阅发布 多级消息推送 分布式推送
  20. unittest常用的断言方法

热门文章

  1. pandas中的quantile函数
  2. Tika教程
  3. SpringBoot2.0拦截器 与 1.X版本拦截器 的实现
  4. poi 处理空单元格
  5. spark优化——依赖包传入HDFS_spark.yarn.jar和spark.yarn.archive的使用
  6. 微信公众号开发笔记-验证token
  7. P4363 [九省联考2018]一双木棋
  8. python调用tushare获取沪深股通十大成交股
  9. Permission denied
  10. window 下搭建流媒体服务器ffmpeg nginx-rmtp-module