poj1329 Circle Through Three Points
来源:互联网 发布:ajax获取json中的数据 编辑:程序博客网 时间:2024/04/27 22:46
Circle Through Three Points
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3130 Accepted: 1325
Description
Your team is to write a program that, given the Cartesian coordinates of three points on a plane, will find the equation of the circle through them all. The three points will not be on a straight line.
The solution is to be printed as an equation of the form
and an equation of the form
The solution is to be printed as an equation of the form
(x - h)^2 + (y - k)^2 = r^2(1)
and an equation of the form
x^2 + y^2 + cx + dy - e = 0(2)
Input
Each line of input to your program will contain the x and y coordinates of three points, in the order Ax, Ay, Bx, By, Cx, Cy. These coordinates will be real numbers separated from each other by one or more spaces.
Output
Your program must print the required equations on two lines using the format given in the sample below. Your computed values for h, k, r, c, d, and e in Equations 1 and 2 above are to be printed with three digits after the decimal point. Plus and minus signs in the equations should be changed as needed to avoid multiple signs before a number. Plus, minus, and equal signs must be separated from the adjacent characters by a single space on each side. No other spaces are to appear in the equations. Print a single blank line after each equation pair.
Sample Input
7.0 -5.0 -1.0 1.0 0.0 -6.01.0 7.0 8.0 6.0 7.0 -2.0
Sample Output
(x - 3.000)^2 + (y + 2.000)^2 = 5.000^2x^2 + y^2 - 6.000x + 4.000y - 12.000 = 0(x - 3.921)^2 + (y - 2.447)^2 = 5.409^2x^2 + y^2 - 7.842x - 4.895y - 7.895 = 0
Source
Southern California 1989,UVA 190
给三个点求圆的方程
推公式,没什么说的,用克莱姆法则解方程可以方便点不用考虑分母0的情况。
#include <stdio.h>#include <math.h>#include <string.h>#include <algorithm>using namespace std;struct Point{ double x,y,z;};double Cal(Point s,Point t){ return (s.x*s.x-t.x*t.x+s.y*s.y-t.y*t.y)/2;}int main(){ Point a[3]; int i; while(scanf("%lf%lf",&a[0].x,&a[0].y)!=EOF) { for (i=1;i<=2;i++) { scanf("%lf%lf",&a[i].x,&a[i].y); } Point a1,a2; a1.x=a[0].x-a[1].x; a2.x=a[0].x-a[2].x; a1.y=a[0].y-a[1].y; a2.y=a[0].y-a[2].y; a1.z=Cal(a[0],a[1]); a2.z=Cal(a[0],a[2]); double x=-(a2.z*a1.y-a1.z*a2.y)/(a2.y*a1.x-a1.y*a2.x); double y=(a2.z*a1.x-a1.z*a2.x)/(a2.y*a1.x-a1.y*a2.x); double r=sqrt((x-a[0].x)*(x-a[0].x)+(y-a[0].y)*(y-a[0].y)); printf("(x %s %.3f)^2 + (y %s %.3f)^2 = %.3f^2\n",x<0?"+":"-",fabs(x),y<0?"+":"-",fabs(y),r); printf("x^2 + y^2 %s %.3fx %s %.3fy %s %.3f = 0\n",2*x<0?"+":"-",fabs(2*x),2*y<0?"+":"-",fabs(2*y),x*x+y*y-r*r>0?"+":"-",fabs(x*x+y*y-r*r)); printf("\n"); } return 0;}
0 0
- poj1329 Circle Through Three Points
- POJ1329-Circle Through Three Points
- poj1329 Circle Through Three Points 三角形外接圆(水)
- POJ1329 Circle Through Three Points(解析几何,圆)
- Circle Through Three Points
- poj 1329 Circle Through Three Points
- poj 1329 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- UVa 190 - Circle Through Three Points
- uva 190 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- uva 190 Circle Through Three Points
- POJ 1329 Circle Through Three Points 笔记
- poj 1329 Circle Through Three Points(三点求圆方程)
- poj 1329 Circle Through Three Points(求三角形外接圆)
- POJ 1329 Circle Through Three Points 求三角形外接圆
- C语言之详解#ifdef等宏
- OSG 第三讲,OSGviewer加入键盘响应
- 存储系统----测量性能(1)
- 学习笔记 unsigned 变量 局部变量 数组溢出
- Ambiguous Permutations
- poj1329 Circle Through Three Points
- jlink linux下调试
- hrbust 1997 又是一个神奇的布尔矩阵
- 黄金连分数
- GitHub之gitignore使用2--git 中.gitignore的使用
- 某大公司Android面试题,JAVA面试题
- excel 之 制作下拉框
- 代理模式 -- 通过代理对象间接访问对象
- C#学习6,文件操作相关学习