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

好象不是额、、、加了之后G++依然WA。。。 附上代码。。。供大家鞭笞。。。

Posted by Zeor at 2009-08-28 20:32:52 on Problem 1269
In Reply To:会不会是输出-0.00?加个fabs看看? Posted by:zhangdaxia at 2009-08-28 20:17:12
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
struct point 
{
	double x,y;
}node[6];

typedef struct point point;

double Mult(double x1,double y1,double x2,double y2)
{
	return fabs(x1*y2-x2*y1);
}

point intersection(point u1,point u2,point v1,point v2)
{
	point ret=u1;
	double t=((u1.x-v1.x)*(v1.y-v2.y)-(u1.y-v1.y)*(v1.x-v2.x))/((u1.x-u2.x)*(v1.y-v2.y)-(u1.y-u2.y)*(v1.x-v2.x));
	ret.x+=(u2.x-u1.x)*t;
	ret.y+=(u2.y-u1.y)*t;
	return ret;
}

int main()
{
	//freopen("PKU1269.in","r",stdin);
	//freopen("PKU1269.out","w",stdout);
	printf ("INTERSECTING LINES OUTPUT\n");
	int n;
	scanf ("%d",&n);
	while (n--)
	{
		for (int i=1;i<=4;i++)
			scanf ("%lf %lf",&node[i].x,&node[i].y);
		if(fabs((node[2].y-node[1].y)*(node[4].x-node[3].x)-(node[2].x-node[1].x)*(node[4].y-node[3].y))<1e-6)
		{
			if(Mult(node[3].x-node[2].x,node[3].y-node[2].y,node[2].x-node[1].x,node[2].y-node[1].y)<=1e-6)
				printf ("LINE\n");
			else
				printf ("NONE\n");
		}
		else
		{
			point co=intersection(node[1],node[2],node[3],node[4]);
			if(fabs(co.x)<1e-6)
				co.x=0;
			if(fabs(co.y)<1e-6)
				co.y=0;
			printf ("POINT %.2lf %.2lf\n",co.x,co.y);
		}
		//system("pause");
	}
	printf ("END OF OUTPUT\n");
//	while(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