#38179:


11131039@stu.tshs.tp.edu.tw (二孝25林孟希)

學校 : 不指定學校
編號 : 201083
來源 : [36.227.70.244]
最後登入時間 :
2024-05-22 06:16:38
g047. 三角形的外心 | From: [36.225.104.248] | 發表日期 : 2023-10-31 22:43

#include <bits/stdc++.h>
using namespace std;

double Determinant(double x1,double x2,double x3,double x4,double x5,double x6,double x7,double x8,double x9)
{
    /// x1 x2 x3
    /// x4 x5 x6
    /// x7 x8 x9
    return (x1*x5*x9)+(x2*x6*x7)+(x3*x4*x8)-(x3*x5*x7)-(x1*x6*x8)-(x2*x4*x9);
}

double sum(double x1,double x2)
{
    return pow(x1,2)+pow(x2,2);
}

int main()
{
    double xa,ya,xb,yb,xc,yc;
    while(cin>>xa>>ya>>xb>>yb>>xc>>yc)
    {
        double mab,mac;
        double x,y;
        mab=(ya-yb)/(xa-xb);
        mac=(ya-yc)/(xa-xc);
        if(mab==mac) cout<<"No circumcenter."<<endl;
        else
        {
            x=(Determinant(sum(xa,ya),ya,1,sum(xb,yb),yb,1,sum(xc,yc),yc,1))/(2*(Determinant(xa,ya,1,xb,yb,1,xc,yc,1)));
            y=(Determinant(xa,sum(xa,ya),1,xb,sum(xb,yb),1,xc,sum(xc,yc),1))/(2*(Determinant(xa,ya,1,xb,yb,1,xc,yc,1)));
            cout<<fixed<<setprecision(3)<<x<<" ";
            cout<<fixed<<setprecision(3)<<y<<endl;
        }
    }
}

 
ZeroJudge Forum