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 tankadozmy at 2010-02-17 21:03:54 on Problem 2780
#include<iostream>
#define N 1002
using namespace std;
struct point
{
	int x ,y;
}p[N];
int main()
{
	int online(int,int,int);
	int n,i,j,k,count,longest;
	while(cin>>n)
	{
		count=2; longest=0;
		for(i=0;i<n;i++)
			scanf("%d%d",&p[i].x,&p[j].y);
		for(i=0;i<n-1;i++)
			for(j=i+1;j<n;j++)
			{
				count=2;
				for(k=j+1;k<n;k++)
				{
					if(online(i,j,k)) count++;
				}
				if(count>longest) longest=count;
			}
		cout<<longest<<endl;
	}
}
int online(int i,int j,int k)
{
   if((p[j].y-p[i].y)*(p[k].x-p[j].x)
           ==(p[k].y-p[j].y)*(p[j].x-p[i].x))
   return 1;
   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