(DS1.5.6)POJ 2242 The Circumference of the Circle(一直三个点的坐标,求外接圆的周长)

/*
 * POJ_2242.cpp
 *
 *  Created on: 2013年10月23日
 *      Author: Administrator
 */

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;


int main(){
	double x1,y1,x2,y2,x3,y3;

	const double PI = 3.141592653589793;
	while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF){
		double a = sqrt(abs(x2-x1)*abs(x2-x1) + abs(y2-y1)*abs(y2-y1));
		double b = sqrt(abs(x2-x3)*abs(x2-x3) + abs(y2-y3)*abs(y2-y3));
		double c = sqrt(abs(x3-x1)*abs(x3-x1) + abs(y3-y1)*abs(y3-y1));

		double p = (a+b+c)/2;

		double s = sqrt(p*(p-a)*(p-b)*(p-c));

		double d = a*b*c/(2*s);//外接圆的直径

        double l = d*PI;

        printf("%.2lf\n",l);
	}

	return 0;
}


你可能感兴趣的:((DS1.5.6)POJ 2242 The Circumference of the Circle(一直三个点的坐标,求外接圆的周长))