Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

附上两种方法

Posted by ccl66 at 2017-08-13 10:23:45 on Problem 2242
海伦公式:
#include<iostream>
#include<cmath>
#include<cstdio>
#define PI 3.141592653589793
using namespace std;
struct Point
{
    double x,y;
}p[4];
double dis(Point a,Point b)
{
    double ans=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
    return ans;
}
int main()
{
    while(cin>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y)
    {

        double a=dis(p[2],p[3]),b=dis(p[1],p[2]),c=dis(p[1],p[3]);
        /**
        double cosa=(b*b+c*c-a*a)/(2*b*c);
        double sina=sqrt(1-cosa*cosa);
        double d=a/sina;
        **/

        double r=a*b*c/sqrt((a+b+c)*(a+b-c)*(a-b+c)*(-a+b+c));   ///海伦公式求r
        printf("%.2f\n",PI*2*r);


    }

    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator