Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
给出公式! 不需要解析几何!先求出3边长,由海伦公式得出面积 S=sqrt(p*(p-a)*(p-b)*(p-c)) p=(a+b+c)/2; 由三角形面积公式S=1/2*a*b*sin(C) 和正弦定理a/sin(A)=b/sin(B)=c/sin(C)=直径 可得直径=a*b*c/2/S; (a,b,c为三边长) 所以周长即为直径*PI 完毕! 下面是A过的代码!不嫌麻烦的可以看看!!! #include<stdio.h> #include<math.h> #define PI 3.141592653589793 double w(double a,double b,double c,double d) //求边长 { double x; x=sqrt((a-c)*(a-c)+(b-d)*(b-d)); return x; } double g(double o,double p,double q) //求三角形面积:海伦公式 { double m=(o+p+q)/2; m=sqrt(m*(m-o)*(m-p)*(m-q)); return m; } double h(double s,double u,double v,double w) //求直径 {double y; y=2*s/u/v; y=w/y; return y; } int main() {double a,b,c,d,e,f,i,j,k,l; while((scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f))!=EOF){ i=w(a,b,c,d); j=w(a,b,e,f); k=w(c,d,e,f); l=g(i,j,k); l=h(l,i,j,k); printf("%.2lf\n",PI*l); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator