现在的位置: 首页 > 综合 > 正文

ZOJ 1090 三点求圆周

2013年03月29日 ⁄ 综合 ⁄ 共 714字 ⁄ 字号 评论关闭

//////////////////////////////////////////////////
//1090一道数学题
//已知三点的坐标,求以此三点所确定的圆的周长
//先用余弦定理cosα=(b^2+c^2-a^2)/(2bc),再求sinα,那么直径d=a/sinα,周长l=dπ
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
#define pi 3.141592653589793

 

int main()
{
    double x1,y1,x2,y2,x3,y3;
    double wer1,wer2,wer3;
    double a,b,c;
    while((cin>>x1>>y1>>x2>>y2>>x3>>y3)!=0)
    {
        wer1=pow((x1-x2),2)+pow((y1-y2),2);
        a=sqrt(wer1);
        wer2=pow((x3-x2),2)+pow((y3-y2),2);
        b=sqrt(wer2);
        wer3=pow((x1-x3),2)+pow((y1-y3),2);
        c=sqrt(wer3);
        double ans;
        ans=(b*b+c*c-a*a)/(2*b*c);
        ans=sqrt(1-ans*ans);
        ans=a*pi/ans;
        cout<<setiosflags(ios::fixed)<<setprecision(2)<<ans<<endl;
    }
    return 0;
}

抱歉!评论已关闭.