题目链接: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. asp.net命名规范

    以下命名规范是在编程中,可以辅助快速编程的良好方式之一,我一点点的整理出来,以便形成自己的编程规范.还有待完善... 0.产品命名规范: 结构 层次 产品 模块 功能 命名规则 UI(界面层) Web ...

  2. iOS 跳转到应用所在的App Store市场

    代码入下 #import "ViewController.h" @interface ViewController ()<UIWebViewDelegate> @end ...

  3. 关于Java中的数组转变成字符串问题

    1.用StringBuilder private static String arraytoString(int arr[]){ StringBuilder sb=new StringBuilder( ...

  4. LCS最长公共子序列HDU1159

    最近一直在学习算法,基本上都是在学习动态规划以及字符串.当然,两者交集最经典之一则是LCS问题. 首先LCS的问题基本上就是在字符串a,b之间找到最长的公共子序列,比如 YAOLONGBLOG 和 Y ...

  5. Eclipse开发android安装环境

    好久没有用Eclipse开发android了,今天安装了一下,发现之前的andorid的sdk不能用了,然后去官网下载了一个最新的SDK,由于现在的android的官网需要FQ才能访问到,所以在这里我 ...

  6. boost::thread 线程锁

    1.boost锁的概述: boost库中提供了mutex类与lock类,通过组合可以轻易的构建读写锁与互斥锁. 2.mutex对象类(主要有两种): 1.boost::mutex(独占互斥类) --& ...

  7. 实现基于文件存储的Session类

    自主实现Session功能的类,基于文件方式存储Session数据,测试基本通过,还比较好玩,实际应用没有意义,只不过是学习Session是如何实现的. 一般基于文件存储Session数据效率不是很高 ...

  8. 转载 VC 2010下安装OpenCV2.4.4

    说明: 1.安装平台:32位XP,VS2010: 2.OpenCV 2.4.4不支持VC 6.0: 3.网上有很多用CMake编译OpenCV的安装教程,这里建议先不要自己编译,如果使用预编译好的库有 ...

  9. ffmpeg与RTMP流媒体连接用法(翻译) http://www.chinavideo.org/forum.php?mod=viewthread&tid=15423

    最近浏览国外网站时候发现,翻译不准确的敬请谅解. 1.将文件当做直播送至liveffmpeg -re -i localFile.mp4 -c copy -f flv rtmp://server/liv ...

  10. clipboard让复制的文本换行

    https://clipboardjs.com/dist/clipboard.min.js 用clipboard实现复制时, 想让复制的文本换行, 有两咱方法: 第一种, HTML实现: <!- ...