三角形的外心

三角形外接圆圆心

Where is the little Jgshining?

#include
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;
}

你可能感兴趣的:(三角形的外心)