三角形的外心

作者: 雨落八千里 | 来源:发表于2019-11-22 18:40 被阅读0次

    三角形外接圆圆心

    Where is the little Jgshining?

    #include<bits/stdc++.h>
    using namespace std;
    double xx1,yy1,xx2,yy2,xx3,yy3;
    int main( )
    {
       int t;
       scanf("%d",&t);
       while(t--)
       {
           scanf("%lf%lf%lf%lf%lf%lf",&xx1,&yy1,&xx2,&yy2,&xx3,&yy3);
           if(xx3==xx1&&yy3==yy1)
           {
               printf("%.1lf %.1lf\n",xx1+xx2/2,yy1+yy2/2);
           }
           else if(yy2==yy3&&xx2==xx3)
           {
               printf("%.1lf %.1lf\n",xx1+xx2/2,yy1+yy2/2);
           }
           else if(yy2==yy1&&xx2==xx1)
           {
               printf("%.1lf %.1lf\n",xx1+xx3/2,yy1+yy3/2);
           }
           else if(((xx3-xx2)*(yy2-yy1)-(xx2-xx1)*(yy3-yy2))==0)
           {
               printf("No this position\n");
           }
           else
           {
               double a=((yy2-yy1)*(yy3*yy3-yy1*yy1+xx3*xx3-xx1*xx1)-(yy3->yy1)*(yy2*yy2-yy1*yy1+xx2*xx2-xx1*xx1))/(2.0*((xx3-xx1)*(yy2-yy1)-(xx2->xx1)*(yy3-yy1)));
               double b=((xx2-xx1)*(xx3*xx3-xx1*xx1+yy3*yy3-yy1*yy1)-(xx3->xx1)*(xx2*xx2-xx1*xx1+yy2*yy2-yy1*yy1))/(2.0*((yy3-yy1)*(xx2-xx1)-(yy2->yy1)*(xx3-xx1)));
               double r=sqrt((xx1-a)*(xx1-a)+(yy1-b)*(yy1-b));
               printf("%.1lf %.1lf\n",a,b);
           }
       }
       return 0;
    }
    

    相关文章

      网友评论

        本文标题:三角形的外心

        本文链接:https://www.haomeiwen.com/subject/ulvqwctx.html