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 pppooo at 2008-10-08 19:08:50 on Problem 1269
#include <iostream>
using namespace std;
int main ()
{
	int n;
	cin >>n;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	double a[10][8];
	for (int i=0;i<n;i++)
		for (int k=0;k<8;k++)
	{
			cin>>a[i][k];

	}
	cout<<"INTERSECTING LINES OUTPUT"<<endl;
	for (int m=0;m<n;m++)
	{
		x1=a[m][0];y1=a[m][1];
		x2=a[m][2];y2=a[m][3];
		x3=a[m][4];y3=a[m][5];
		x4=a[m][6];y4=a[m][7];
		double X,Y;
		if (x1==x2&&x3!=x4)
		{
			X=x1;
			Y=((y4-y3)/(x4-x3))*(X-x3)+y3;
		}
		else if (x3==x4&&x1!=x2)
		{
			X=x3;
			Y=((y2-y1)/(x2-x1))*(X-x1)+y1;
		}
		else if (((y1==y2)&&(y3==y4))||((x1==x2)&&(x3==x4))||((y4-y3)/(x4-x3)==(y4-y1)/(x4-x1))&&((y4-y3)/(x4-x3)==(y2-y1)/(x2-x1)))
		{
			cout<<"LINE"<<endl;
		     continue;
		}
		else if (((y1==y2)&&(y2==y3)&&(y3==y4))||((x1==x2)&&(x2==x3)&&(x3==x4))||((y4-y3)/(x4-x3)==(y2-y1)/(x2-x1))&&((y4-y3)/(x4-x3)!=(y4-y3)/(x2-x1)))
		{
			cout<<"NONE"<<endl;
			continue;
		}
		else if (((y4-y3)/(x4-x3)!=(y2-y1)/(x2-x1)))		
		{
			 X=(y3-y1-((y4-y3)/(x4-x3))*x3+((y2-y1)/(x2-x1))*x1)/(((y2-y1)/(x2-x1))-((y4-y3)/(x4-x3)));
		     Y=(((y4-y3)/(x4-x3))*y1-((y2-y1)/(x2-x1))*y3+((y2-y1)/(x2-x1))*((y4-y3)/(x4-x3))*x3-((y4-y3)/(x4-x3))*((y2-y1)/(x2-x1))*x1)/(((y4-y3)/(x4-x3))-((y2-y1)/(x2-x1)));
		}
			 cout<<"POINT ";
			 printf("%.2lf",X);
			 cout<<" ";
		     printf("%.2lf\n",Y);
	}		
	cout<<"END OF OUTPUT"<<endl;
	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