POJ 2242
1 #include <iostream> 2 #include <cmath> 3 #include <iomanip> 4 using namespace std; 5 #define PI 3.141592653589793 6 7 struct node 8 { 9 double x; 10 double y; 11 }; 12 13 node p_1; 14 node p_2; 15 node p_3; 16 17 double a; 18 double b; 19 double c; 20 double give_len(node a,node b); 21 22 int main() 23 { 24 //freopen("acm.acm","r",stdin); 25 double cos_c; 26 double sin_c; 27 double s; 28 while(cin>>p_1.x>>p_1.y>>p_2.x>>p_2.y>>p_3.x>>p_3.y) 29 { 30 a = give_len(p_1,p_2); 31 b = give_len(p_1,p_3); 32 c = give_len(p_2,p_3); 33 // cout<<"--- a"<<a<<endl; 34 // cout<<b<<endl; 35 // cout<<c<<endl; 36 cos_c = (a*a + b*b - c*c)/(2.0*a*b); 37 sin_c = sqrt((1 - cos_c*cos_c)); 38 s = 0.5 * a*b*sin_c; 39 cout<<setiosflags(ios::fixed)<<setprecision(2)<<a*b*c*PI/(s*2.0)<<endl; 40 } 41 } 42 43 double give_len(node a,node b) 44 { 45 return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y - b.y)*(a.y - b.y) ); 46 }