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

输出很蛋疼,要考虑系数为0,输出也不同

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
const double INF = 1000000000000000.000; struct Point
{
double x,y;
Point(double x=, double y=) : x(x),y(y) { } //构造函数
};
typedef Point Vector; struct Circle
{
Point c;
double r;
Circle() {}
Circle(Point c,double r): c(c),r(r) {}
};
Vector operator + (Vector A , Vector B)
{
return Vector(A.x+B.x,A.y+B.y);
}
Vector operator - (Vector A , Vector B)
{
return Vector(A.x-B.x,A.y-B.y);
}
Vector operator * (Vector A, double p)
{
return Vector(A.x*p,A.y*p);
}
Vector operator / (Vector A , double p)
{
return Vector(A.x/p,A.y/p);
} bool operator < (const Point& a,const Point& b)
{
return a.x < b.x ||( a.x == b.x && a.y < b.y);
} int dcmp(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b)
{
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} ///向量(x,y)的极角用atan2(y,x);
inline double Dot(Vector A, Vector B)
{
return A.x*B.x + A.y*B.y;
}
inline double Length(Vector A)
{
return sqrt(Dot(A,A));
}
inline double Angle(Vector A, Vector B)
{
return acos(Dot(A,B) / Length(A) / Length(B));
}
double Cross(Vector A, Vector B)
{
return A.x*B.y - A.y * B.x;
}
Vector vecunit(Vector v)
{
return v / Length(v); //单位向量
} Point read_point()
{
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
}
Vector Normal(Vector A)
{
double L = Length(A);
return Vector(-A.y/L, A.x/L);
}
Point GetLineIntersecion(Point P, Vector v,Point Q,Vector w)
{
Vector u = P - Q;
double t = Cross(w,u)/Cross(v,w);
return P + v*t;
} //多边形
//求面积
double PolygonArea(Point* p,int n) //n个点
{
double area = ;
for(int i=; i<n-; i++)
{
area += Cross(p[i]-p[],p[i+]-p[]);
}
return area/;
} /*************************************分 割 线*****************************************/ int main()
{
//freopen("E:\\acm\\input.txt","r",stdin); Point A,B,C,O;
double R;
while(scanf("%lf %lf %lf %lf %lf %lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y) == )
{ Point mid1 = (A+B)/;
Point mid2 = (B+C)/;
Vector v1 = Normal(A-B);
Vector v2 = Normal(B-C); O = GetLineIntersecion(mid1,v1,mid2,v2);
R = Length(O-A); if(dcmp(O.x)>) printf("(x - %.3f)^2 + ",O.x);
else if(dcmp(O.x) == ) printf("x^2 + ",O.x);
else printf("(x + %.3f)^2 + ",-O.x);
if(dcmp(O.y)>) printf("(y - %.3f)^2 = ",O.y);
else if(dcmp(O.y) == ) printf("y^2 = ",O.y);
else printf("(y + %.3f)^2 = ",-O.y);
printf("%.3f^2\n",R); if(dcmp(O.x)>) printf("x^2 + y^2 - %.3fx ",*O.x);
else if(dcmp(O.x) == ) printf("x^2 + y^2 ");
else printf("x^2 + y^2 + %.3fx ",-*O.x); if(dcmp(O.y)>) printf("- %.3fy ",*O.y);
else if(dcmp(O.y) < ) printf("+ %.3fy ",-*O.y); if(dcmp(O.x*O.x+O.y*O.y-R*R) > )
printf("+ %.3f = 0\n",O.x*O.x+O.y*O.y-R*R);
else if(dcmp(O.x*O.x+O.y*O.y-R*R) == )
printf("= 0\n");
else
printf("- %.3f = 0\n",-O.x*O.x-O.y*O.y+R*R);
printf("\n");
}
}

poj 1329 Circle Through Three Points(求圆心+输出)的更多相关文章

  1. POJ - 1329 Circle Through Three Points 求圆

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4112   Acce ...

  2. ●POJ 1329 Circle Through Three Points

    题链: http://poj.org/problem?id=1329 题解: 计算几何,求过不共线的三点的圆 就是用向量暴力算出来的东西... (设出外心M的坐标,由于$|\vec{MA}|=|\ve ...

  3. POJ 1329 Circle Through Three Points(三角形外接圆)

    题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...

  4. POJ 1329 Circle Through Three Points(三角形外心)

    题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...

  5. poj 1329(已知三点求外接圆方程.)

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3766   Acce ...

  6. UVALive 4639 && SPOJ SPOINTS && POJ 3805 && AOJ 1298 Separate Points 求两个凸包是否相交 难度:3

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  7. poj1329 Circle Through Three Points

    地址:http://poj.org/problem?id=1329 题目: Circle Through Three Points Time Limit: 1000MS   Memory Limit: ...

  8. POJ 1329 三角外接圆

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3169   Acce ...

  9. POJ 3259 Wormholes(最短路径,求负环)

    POJ 3259 Wormholes(最短路径,求负环) Description While exploring his many farms, Farmer John has discovered ...

随机推荐

  1. iOS-UI控件精讲之UILabel

    UILabel(标签)应该是iOS中最基本的一个控件了,也是使用频率最高的,经常用来展示一段不可编辑的文本. UILabel继承于UIView,下面是一些常用的属性,包含继承于UIView的属性. 1 ...

  2. cocos2dx系列笔记(2)- windows环境配置后续之 Android环境配置

    续上篇 对于想用cocos2dx来开发Android游戏的人来说,最痛苦的莫过于配置Android环境和之后的奇奇怪怪的编译失败问题.这是经历了多次成功与失败之后,血与泪的经验包,大家请收好.如果你有 ...

  3. HDU1557权利选举

    /* 思路:遍历所有2^n个集合,对于每个集合求票和,如果满足票为优胜团体,而再对集合每个成员比较,是否满足变成非优胜团体,是的话,对于该成员对应结果+1. 重点:利用二进制思想,所有团体均对应0~2 ...

  4. 将CString(unicode)转换为char*(ANSI)

    1.将CString(unicode)转换为char*(ANSI) CString strServIP; pChat->GetDlgItemText(IDC_IP,strServIP); ] = ...

  5. 网络基础---OSI 模型与TCP/IP

    一.网络的演进: 1.简单的联接:1960's ------------ 1970's    Host Network 六十至七十年代,网络的概念主要是主机架构的低速串行联接,提供应用程序执行.远程打 ...

  6. 配置nginx1.7.8支持pathinfo模式

    vi nginx/conf/nginx.conf 1.修改正则 set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ...

  7. asp.net中的<%%>形式的详细用法实例讲解

    asp.net中的代码分离模式我们肯定都不陌生,C#(或者其它语言)写的代码一般不会和设计语言HTML混在一起,但是有的时候也避免不了,这时就会在UI页面里用<%%>来绑定显示.绑定变量数 ...

  8. Python 基础-python环境变量、模块初识及字符类型

    (1).模块内置模块.第三方模块.自定义模块初识模块:sys \ os一般标准库存放路径 C:\Users\Administrator\AppData\Local\Programs\Python\Py ...

  9. (转) 关于成为linux运维工程师需要掌握的技能

    曾经在一年多前写了一篇关于要成为linux运维需要掌握哪些技能和工具的贴子,然后不小心被好几个网友抄袭转发到其它网站上,当然有些是认识的,最后还很幸运地被某些热心的学习者把那段内容剪下来当作圣经般的参 ...

  10. 《将博客搬至CSDN》 分类: 勉励自己 2014-09-05 14:29 43人阅读 评论(0) 收藏

    搬家啦,上博客园关注我哦http://www.cnblogs.com/AsuraRoute 版权声明:本文为博主原创文章,未经博主允许不得转载.