ZOJ1090 The Circumference of the Circle

简介:
  计算几何题,使用的数学公式参考http://topic.csdn.net/t/20050329/22/3892541.html

复制代码
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

const double PI = 3.141592653589793;
double Distance(double x1,double y1,double x2,double y2)
{//两点间的距离
    double deltaX = x1-x2;
    double deltaY = y1-y2;
    return sqrt(deltaX*deltaX+deltaY*deltaY);
}
double CaculateCircum(double x1,double y1,double x2,double y2,double x3,double y3)
{//计算三角形外接圆周长
    //海伦公式计算三角形面积
    double a,b,c,L,S;
    a = Distance(x1,y1,x2,y2);
    b = Distance(x2,y2,x3,y3);
    c = Distance(x1,y1,x3,y3);
    L = (a+b+c)/2;
    S = sqrt(L*(L-a)*(L-b)*(L-c));
//计算三角形外接圆周长
    return PI*a*b*c/(2*S);
}
int main(void)
{
    double x1,y1,x2,y2,x3,y3,circum;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3)
    {
        circum = CaculateCircum(x1,y1,x2,y2,x3,y3);
        cout<<fixed<<setprecision(2)<<circum<<endl;
    }
    return 0;
}
复制代码


本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/10/31/1323492.html,如需转载请自行联系原作者
目录
相关文章
|
测试技术
POJ3687---Labeling Balls
POJ3687---Labeling Balls
POJ3687---Labeling Balls
|
机器学习/深度学习
HDOJ/HDU 1556 Color the ball(树状数组)
HDOJ/HDU 1556 Color the ball(树状数组)
102 0
|
Java Go
POJ 1163 The Triangle
POJ 1163 The Triangle
102 0
ZOJ1067 Color Me Less
复制代码#include <iostream> #include <cmath> #include <limits> using namespace std; const int MAXSIZE = 100; int pos[100];//记录对应的最小值所在位置 struct RGB {//颜.
1456 0
|
Java 机器学习/深度学习
HDU 1556 Color the ball
Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18404    Accepted Submission(s...
830 0
poj-1163-The Triangle
Description 73 88 1 02 7 4 44 5 2 6 5(Figure 1) Figure 1 shows a number triangle.
687 0
poj-1046-color me less
Description A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires that you perform jus...
952 0
|
人工智能 Java Go
POJ 1163 The Triangle
The Triangle Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total Submission(s) : 23 Accepted Submiss...
947 0