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

Re:第一道几何题目!很给

Posted by chenxuan123456789 at 2012-08-10 16:52:33 on Problem 1269
In Reply To:第一道几何题目!很给 Posted by:chenxuan123456789 at 2012-08-10 16:52:15
#include <stdio.h>
#include <math.h>
double a[2][2];
double b[2][2];
int main()
{
	int cases;
	printf("INTERSECTING LINES OUTPUT\n");
	scanf("%d",&cases);
	while(cases--)
	{
	 scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a[0][0],&a[0][1],&a[1][0],&a[1][1],&b[0][0],&b[0][1],&b[1][0],&b[1][1]);
	 //printf("%lf %lf %lf %lf %lf %lf %lf %lf\n",a[0][0],a[0][1],a[1][0],a[1][1],b[0][0],b[0][1],b[1][0],b[1][0],b[1][1]);
	 double a1,a2;
	 double b1,b2;
	 double k1,k2,k11,k22;
	 a1=a[1][0]-a[0][0];
	 a2=a[1][1]-a[0][1];
	 b1=b[1][0]-b[0][0];
	 b2=b[1][1]-b[0][1];
	// printf("%lf %lf %lf %lf\n",a1,a2,b1,b2);
	 if(a1*b2==a2*b1)
	 {
		 if(a2/a1*(-a[0][0])+a[0][1]==b2/b1*(-b[0][0])+b[0][1])
		 printf("LINE\n");
		 else
		 printf("NONE\n");
	 }
	 else
	 {
		 if(a1==0||b1==0)
		 {
			if(a1==0)
			{
				printf("POINT %.2f",a[0][0]);
				k2=b2/b1;
				printf(" %.2f\n",k2*(a[0][0]-b[0][0])+b[0][1]);
			}
			else
			if(b1==0)
			{
				printf("POINT %.2f",b[0][0]);
				k1=a2/a1;
				printf(" %.2f\n",k1*(b[0][0]-a[0][0])+a[0][1]);
			}
		 }
		 else
		 {
		 k1=a2/a1;
		 k2=b2/b1;
		 k11=k1*(-a[0][0])+a[0][1];
		 k22=k2*(-b[0][0])+b[0][1];
		 printf("POINT %.2f %.2f\n",((k22-k11)/(k1-k2)),((k11*k2-k22*k1)/(k2-k1)));
		 }
	 }
	}
	printf("END OF OUTPUT\n");
	return 1;
}



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