POJ 1329 Circle Through Three Points(三角形外心)
抄的外心模版。然后,输出认真一点。1Y。
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
#define eps 1e-8
struct point
{
double x,y;
};
struct line
{
point a,b;
};
point intersection(line u,line v)
{
point ret = u.a;
double t = ((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))
/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
ret.x += (u.b.x-u.a.x)*t;
ret.y += (u.b.y-u.a.y)*t;
return ret;
}
point circumcenter(point a,point b,point c)
{
line u,v;
u.a.x = (a.x+b.x)/;
u.a.y = (a.y+b.y)/;
u.b.x = u.a.x - a.y + b.y;
u.b.y = u.a.y + a.x - b.x;
v.a.x = (a.x+c.x)/;
v.a.y = (a.y+c.y)/;
v.b.x = v.a.x - a.y + c.y;
v.b.y = v.a.y + a.x - c.x;
return intersection(u,v);
}
double dis(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y));
}
int main()
{
point p1,p2,p3,cr;
double r,c,d,e;
while(scanf("%lf%lf",&p1.x,&p1.y)!=EOF)
{
scanf("%lf%lf",&p2.x,&p2.y);
scanf("%lf%lf",&p3.x,&p3.y);
cr = circumcenter(p1,p2,p3);
r = dis(cr,p1);
cr.x = -cr.x;
cr.y = -cr.y;
if(cr.x > -eps)
printf("(x + %.3f)^2",cr.x+eps);
else
printf("(x - %.3f)^2",-(cr.x+eps));
if(cr.y > -eps)
printf(" + (y + %.3lf)^2 = ",cr.y+eps);
else
printf(" + (y - %.3lf)^2 = ",-(cr.y+eps));
printf("%.3lf^2\n",r+eps);
c = cr.x*;
d = cr.y*;
e = cr.x*cr.x + cr.y*cr.y - r*r;
printf("x^2 + y^2 ");
if(c > -eps)
printf("+ %.3fx ",c+eps);
else
printf("- %.3fx ",-(c+eps));
if(d > -eps)
printf("+ %.3fy ",d+eps);
else
printf("- %.3fy ",-(d+eps));
if(e > -eps)
printf("+ %.3f = 0\n\n",e+eps);
else
printf("- %.3f = 0\n\n",-(e+eps));
}
}
POJ 1329 Circle Through Three Points(三角形外心)的更多相关文章
- POJ 1329 Circle Through Three Points(三角形外接圆)
题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...
- 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 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...
- poj 1090:The Circumference of the Circle(计算几何,求三角形外心)
The Circumference of the Circle Time Limit: 2 Seconds Memory Limit: 65536 KB To calculate the c ...
- 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 1329(已知三点求外接圆方程.)
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3766 Acce ...
- poj 1981 Circle and Points
Circle and Points Time Limit: 5000MS Memory Limit: 30000K Total Submissions: 8131 Accepted: 2899 ...
随机推荐
- ***CI的CLI运行方式
linux下的执行命令: 1.PHP解释器 2.CI根目录的index.php 3.控制器所在的文件夹 4. 控制器名称 5. 方法名称 (参数) 参考文献: http://codeigni ...
- Linux桌面选型
Arch Linux 官方仓库提供的桌面环境有 Cinnamon: cinnamon Enlightenment: enlightenment17 GNOME: gnome gnome-extra K ...
- HDU3434 Sequence Adjustment
题意:给你含有n个数的序列,每次你可以选一个子序列将上面所有的数字加1或者减1,目标是把所有数字变成相同的,问最少步数,和那个相同的数字有多少种可能. 将原序列转化为差分序列,即a[2] - a[1] ...
- mysql 查询优化规则
.请不要在SELECT中使用DISTINCT: #会用到临时表 .尽可能不要SELECT *,而应该查询需要用到的指定几个字段: .不要对两个大表进行联合,无论是内联或外联.对于需要对两个或多个表进行 ...
- php判断访问的当前设备是手机还是电脑
<?php function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AG ...
- 协处理器,王明学learn
协处理器 协处理器用于执行特定的处理任务,如:数学协处理器可以控制数字处理,以减轻处理器的负担.ARM可支持多达16个协处理器,其中CP15是最重要的一个. CP15提供16组寄存器 通过提供的16组 ...
- C语言字符串长度(转)
C语言字符串长度的计算是编程时常用到的,也是求职时必考的一项. C语言本身不限制字符串的长度,因而程序必须扫描完整个字符串后才能确定字符串的长度. 在程序里,一般会用strlen()函数或sizeof ...
- hdu 3183(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183 思路:比较前后两个相邻的字符,如果前面一个字符大于后面一个字符,就把它去掉. #include ...
- Linux学习笔记(21) Linux日志管理
1. 简介 (1) 日志服务 在CentOS 6.x中日志服务已经由rsyslogd取代了原先的syslogd服务.rsyslogd日志服务更加先进,功能更多.但是不论该服务的使用,还是日志文件的格式 ...
- sql 根据指定条件获取一个字段批量获取数据插入另外一张表字段中+MD5加密
/****** Object: StoredProcedure [dbo].[getSplitValue] Script Date: 03/13/2014 13:58:12 ******/ SET A ...