#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,d,e,f,x,y,r,cont;
double m,n;
while(cin>>a>>b)
{
cin>>c>>d;
cin>>e>>f;
x=((b-d)*(e*e+f*f)+(d-f)*(a*a+b*b)-(b-f)*(c*c+d*d))/(2.0*(((a-c)*(b-f))-(b-d)*(a-e)));
y=((a-e)*(c*c+d*d)+(e-c)*(a*a+b*b)-(a-c)*(e*e+f*f))/(2.0*(((a-c)*(b-f))-(b-d)*(a-e)));
r=sqrt(((a-x)*(a-x))+((b-y)*(b-y)));
cont=x*x+y*y-r*r;
m=2.0*x;
n=2.0*y;
if(x<0&&y<0)
{
printf("(x + %.3f)^2 + (y + %.3f)^2 = %.3f^2\n",-x,-y,r);
if(cont<0)
printf("x^2 + y^2 + %.3fx + %.3fy - %.3f = 0\n",-m,-n,-cont);
else if(cont==0)
printf("x^2 + y^2 + %.3fx + %.3fy = 0\n",-m,-n);
else
printf("x^2 + y^2 + %.3fx + %.3fy + %.3f = 0\n",-m,-n,cont);
}
else if(x<0&&y>=0)
{
printf("(x + %.3f)^2 + (y - %.3f)^2 = %.3f^2\n",-x,y,r);
if(cont<0)
printf("x^2 + y^2 + %.3fx - %.3fy - %.3f = 0\n",-m,n,-cont);
else if(cont==0)
printf("x^2 + y^2 + %.3fx - %.3fy = 0\n",-m,n);
else
printf("x^2 + y^2 + %.3fx - %.3fy + %.3f = 0\n",-m,n,cont);
}
else if(x>=0&&y<0)
{
printf("(x - %.3f)^2 + (y + %.3f)^2 = %.3f^2\n",x,-y,r);
if(cont<0)
printf("x^2 + y^2 - %.3fx + %.3fy - %.3f = 0\n",m,-n,-cont);
else if(cont==0)
printf("x^2 + y^2 - %.3fx + %.3fy = 0\n",m,-n);
else
printf("x^2 + y^2 - %.3fx + %.3fy + %.3f = 0\n",m,-n,cont);
}
else if(x>=0&&y>=0)
{
printf("(x - %.3f)^2 + (y - %.3f)^2 = %.3f^2\n",x,y,r);
if(cont<0)
printf("x^2 + y^2 - %.3fx - %.3fy - %.3f = 0\n",m,n,-cont);
else if(cont==0)
printf("x^2 + y^2 - %.3fx - %.3fy = 0\n",m,n);
else
printf("x^2 + y^2 - %.3fx - %.3fy + %.3f = 0\n",m,n,cont);
}
printf("\n");
}
return 0;
}
using namespace std;
int main()
{
double a,b,c,d,e,f,x,y,r,cont;
double m,n;
while(cin>>a>>b)
{
cin>>c>>d;
cin>>e>>f;
x=((b-d)*(e*e+f*f)+(d-f)*(a*a+b*b)-(b-f)*(c*c+d*d))/(2.0*(((a-c)*(b-f))-(b-d)*(a-e)));
y=((a-e)*(c*c+d*d)+(e-c)*(a*a+b*b)-(a-c)*(e*e+f*f))/(2.0*(((a-c)*(b-f))-(b-d)*(a-e)));
r=sqrt(((a-x)*(a-x))+((b-y)*(b-y)));
cont=x*x+y*y-r*r;
m=2.0*x;
n=2.0*y;
if(x<0&&y<0)
{
printf("(x + %.3f)^2 + (y + %.3f)^2 = %.3f^2\n",-x,-y,r);
if(cont<0)
printf("x^2 + y^2 + %.3fx + %.3fy - %.3f = 0\n",-m,-n,-cont);
else if(cont==0)
printf("x^2 + y^2 + %.3fx + %.3fy = 0\n",-m,-n);
else
printf("x^2 + y^2 + %.3fx + %.3fy + %.3f = 0\n",-m,-n,cont);
}
else if(x<0&&y>=0)
{
printf("(x + %.3f)^2 + (y - %.3f)^2 = %.3f^2\n",-x,y,r);
if(cont<0)
printf("x^2 + y^2 + %.3fx - %.3fy - %.3f = 0\n",-m,n,-cont);
else if(cont==0)
printf("x^2 + y^2 + %.3fx - %.3fy = 0\n",-m,n);
else
printf("x^2 + y^2 + %.3fx - %.3fy + %.3f = 0\n",-m,n,cont);
}
else if(x>=0&&y<0)
{
printf("(x - %.3f)^2 + (y + %.3f)^2 = %.3f^2\n",x,-y,r);
if(cont<0)
printf("x^2 + y^2 - %.3fx + %.3fy - %.3f = 0\n",m,-n,-cont);
else if(cont==0)
printf("x^2 + y^2 - %.3fx + %.3fy = 0\n",m,-n);
else
printf("x^2 + y^2 - %.3fx + %.3fy + %.3f = 0\n",m,-n,cont);
}
else if(x>=0&&y>=0)
{
printf("(x - %.3f)^2 + (y - %.3f)^2 = %.3f^2\n",x,y,r);
if(cont<0)
printf("x^2 + y^2 - %.3fx - %.3fy - %.3f = 0\n",m,n,-cont);
else if(cont==0)
printf("x^2 + y^2 - %.3fx - %.3fy = 0\n",m,n);
else
printf("x^2 + y^2 - %.3fx - %.3fy + %.3f = 0\n",m,n,cont);
}
printf("\n");
}
return 0;
}
No comments:
Post a Comment