Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

克拉默法则,附代码

Posted by yzhw at 2011-06-19 12:52:37 on Problem 1329 and last updated at 2011-06-19 12:53:02
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator