zoj1392

来源:互联网 发布:女生好听的英文名知乎 编辑:程序博客网 时间:2024/06/11 03:31
# include <stdio.h># include <math.h>struct node{    double x,y;};node inser(node a,node b,node c,node d){    node f=a;    double t=((a.x-c.x)*(c.y-d.y)-(a.y-c.y)*(c.x-d.x))/((a.x-b.x)*(c.y-d.y)-(a.y-b.y)*(c.x-d.x));    f.x+=(b.x-a.x)*t;    f.y+=(b.y-a.y)*t;    return f;}int main (){    node a,b,c,d,e;    while(scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)!=EOF)    {        d.x=(a.x+b.x)/2.0;        d.y=(a.y+b.y)/2.0;        e.x=(b.x+c.x)/2.0;        e.y=(b.y+c.y)/2.0;        node d1,e1;        d1.x=d.x-(a.y-b.y);        d1.y=d.y+(a.x-b.x);        e1.x=e.x-(b.y-c.y);        e1.y=e.y+(b.x-c.x);        node t=inser(e1,e,d,d1);        double  r=sqrt((t.x-a.x)*(t.x-a.x)+(t.y-a.y)*(t.y-a.y));        double e=t.x*t.x+t.y*t.y-r*r;        char k1='-',k2='-',k3='-';        if(t.x<0.0)  k1='+';        if(t.y<0.0)  k2='+';        if(e>0.0)    k3='+';        printf("(x %c %.3lf)^2 + (y %c %.3lf)^2 = %.3lf^2\n",k1,fabs(t.x),k2,fabs(t.y),r);        printf("x^2 + y^2 %c %.3lfx %c %.3lfy %c %.3lf = 0\n",k1,2*fabs(t.x),k2,2*fabs(t.y),k3,fabs(e));        printf("\n");    }    return 0;}
水题吧 求外接圆的半径还有圆心。。但是两条直线求交点的那个公式背不下来啊。。。。。。。
0 0