zoj 1090 The Circumference of the Circle

//利用余弦和正弦公式就可以很容易求出半径了!
#include "iostream"
#include "cmath"
#include "cstdio"
using namespace std;

const double pi = 3.141592653589793;

int main()
{
	double x1, y1, x2, y2, x3, y3;
	double a2, b2, c2, r;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3)
	{
		a2 = (x3-x2)*(x3-x2) + (y3-y2)*(y3-y2);
		b2 = (x3-x1)*(x3-x1) + (y3-y1)*(y3-y1);
		c2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
		r = sqrt(c2/(1-(a2 + b2 - c2)*(a2 + b2 - c2)/a2/b2/4)/4);
		printf("%.2lf\n", 2*pi*r);
	}
}

你可能感兴趣的:(c)