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 |
克拉默法则,附代码Source Code Problem: 1329 User: yzhw Memory: 412K Time: 0MS Language: GCC Result: Accepted Source Code # include <stdio.h> # include <math.h> # define sig(pos) (fabs(pos)<1e-6||pos>0?'+':'-') double c1[3],c2[3],c3[3]={1,1,1},r[3]; double det(double c1[],double c2[],double c3[]) { return c1[0]*(c2[1]*c3[2]-c2[2]*c3[1])- c2[0]*(c1[1]*c3[2]-c1[2]*c3[1])+ c3[0]*(c1[1]*c2[2]-c2[1]*c1[2]); } int main() { while(scanf("%lf%lf%lf%lf%lf%lf",c1+0,c2+0,c1+1,c2+1,c1+2,c2+2)!=EOF) { int i; double c,d,e,aa,bb,rr; for(i=0;i<3;i++) r[i]=-(c1[i]*c1[i]+c2[i]*c2[i]); c=det(r,c2,c3)/det(c1,c2,c3); d=det(c1,r,c3)/det(c1,c2,c3); e=det(c1,c2,r)/det(c1,c2,c3); aa=c/2; bb=d/2; rr=sqrt(-e+0.25*c*c+0.25*d*d); printf("(x %c %.3f)^2 + (y %c %.3f)^2 = %.3f^2\n",sig(aa),fabs(aa),sig(bb),fabs(bb),rr); printf("x^2 + y^2 %c %.3fx %c %.3fy %c %.3f = 0\n\n",sig(c),fabs(c),sig(d),fabs(d),sig(e),fabs(e)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator