zoj 1090 The Circumference of the Circle

本文介绍了一个简单的算法,用于通过三个给定点来确定一个圆的圆心位置及其半径。该算法利用线性代数原理,适用于解决几何问题,如求解三角形的外接圆。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

模版题,求三点定圆,求三角行的外心

数学都记不得了,,

#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
struct point
{
   double x,y;
   point() {}
   point(double a,double b):x(a),y(b) {}
};

point CircumCenter(point a,point b,point c)
{
    point cp;
    double a1=b.x-a.x,b1=b.y-a.y,c1=(a1*a1+b1*b1)/2;
    double a2=c.x-a.x,b2=c.y-a.y,c2=(a2*a2+b2*b2)/2;
    double d=a1*b2-a2*b1;
    cp.x=a.x+(c1*b2-c2*b1)/d;
    cp.y=a.y+(a1*c2-a2*c1)/d;
    return cp;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    point a,b,c;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)!=EOF){
        point cp=CircumCenter(a,b,c);
        double r=sqrt(pow(cp.x-a.x,2.0)+pow(cp.y-a.y,2.0));
        printf("%.2f\n",2*r*PI);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值