又因為Sin^2C+cos^2C=1;將余弦定理和正弦定理帶入此式可得出外接圓的半徑;
#include#include #include using namespace std; #define PI 3.141592653589793 double DI(double x1,double y1,double x2,double y2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } int main() { double x1,y1,x2,y2,x3,y3,ans,r,s,p; while(cin>>x1>>y1>>x2>>y2>>x3>>y3) { double a,b,c; a=DI(x1,y1,x2,y2); b=DI(x1,y1,x3,y3); c=DI(x2,y2,x3,y3); p=(a+b+c)/2.0; s=sqrt(p*(p-a)*(p-b)*(p-c));//海倫公式求三角形面積 r=(a*b*c)/(4.0*s);//利用三角形面積和外接圓半徑 ans=2*PI*r; cout<