poj 1329 Circle Through Three Points(求圆心+输出)
题目链接: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(求圆心+输出)的更多相关文章
- POJ - 1329 Circle Through Three Points 求圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4112 Acce ...
- ●POJ 1329 Circle Through Three Points
题链: http://poj.org/problem?id=1329 题解: 计算几何,求过不共线的三点的圆 就是用向量暴力算出来的东西... (设出外心M的坐标,由于$|\vec{MA}|=|\ve ...
- POJ 1329 Circle Through Three Points(三角形外接圆)
题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...
- POJ 1329 Circle Through Three Points(三角形外心)
题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...
- poj 1329(已知三点求外接圆方程.)
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3766 Acce ...
- 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 ...
- poj1329 Circle Through Three Points
地址:http://poj.org/problem?id=1329 题目: Circle Through Three Points Time Limit: 1000MS Memory Limit: ...
- POJ 1329
三角外接圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3169 Acce ...
- POJ 3259 Wormholes(最短路径,求负环)
POJ 3259 Wormholes(最短路径,求负环) Description While exploring his many farms, Farmer John has discovered ...
随机推荐
- jquery 中$('.ui-selecter',this)这样写 是什么意思 求解释 见到都是这种$("div")
如果用$("div")是拿选择所有的div$('.ui-selecter',this)选择的是现在选项中的child里面class是ui-selecter的意思跟jQuery(th ...
- spring配置文件中属性mappingLocations、mappingDirectoryLocations
http://blog.csdn.net/vacblog/article/details/7774173
- JS常用的7中跨域方式总结
javascript跨域有两种情况: 1.基于同一父域的子域之间,如:a.c.com和b.c.com 2.基于不同的父域之间,如:www.a.com和www.b.com 3.端口的不同,如:ww ...
- C++学习笔记-2-构造函数和析构函数
问题2. 什么时候执行构造函数和析构函数 22:59:40 2015-07-22 做了一个实验: #include <iostream> class Object{ public: Ob ...
- c#配置文件appStrings配置节的读取、添加和修改
程序开发中经常会用到应用程序配置文件,好处就是维护人员可以直接修改配置文件进行维护,而不用修改程序.好,切入主题. 给项目添加应用程序配置文件App.config,先在里面写几句: <?xml ...
- 将VIM配置成强大的IDE(三)
上一节,我们知道了,我们了解了怎么配置插件的下下载. 现在,我们就可以去DIY我们的IDE了,主要介绍taglist插件和NERDTree插件,最终的结果是: 1.安装Taglist插件. Tagli ...
- PHPCMS标签:get标签
GET标签源自于PHPCMS 2008版,其使用SQL语句直接获取数据的特性,成为大家制作模板的首选. 在V9中这样强大的工具也得到保留下来. GET标签使用方式如下: {pc:get sql=&qu ...
- 从文章"避免复制与粘贴"到文章"Extract Method"的反思(3)
在牛人的博客中提到了..如果你的代码可以copy-past的时候,那么久证明你的代码出现了重复.而这种重复仅仅是虚假的代码行的增加而不是像其他的代码复用那样降级成本. copy-pase代码意味着你违 ...
- [转载]为什么使用%lf读取double型的值,而用%f进行显示?
博客地址:http://blog.csdn.net/shenzhou111/article/details/7826444 今天看到一篇好文章,mark一下. 出去旅游了一下,所以有些天没敲代码,于是 ...
- 正则表达式替换img标签src值!!!
方法一: 相关链接:http://bbs.csdn.net/topics/320185735 实例:此实例自己做的时候讲字符串加了alt进行了有关修改 不清楚看上面链接 string test = ...