| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WA 求围观 求解脱 。。#include"stdio.h"
#include"stdlib.h"
#define N 700
int lineCount(struct Poin *point,int n);
int judge(int *a,int *b);
struct Poin
{
int x;
int y;
};
void main()
{
int i,j,n;
struct Poin point[N];
while(1)
{
scanf("%d",&n);
if(n==0)
break;
for(i=0;i<n;i++)
scanf("%d %d",&point[i].x,&point[i].y);
//j=lineCount(point,n);
printf("%d\n",lineCount(point,n));
}
system("pause");
}
int lineCount(struct Poin *point,int n)
{
int i,j,k,lineC=3,temp=2;
int p[2]={0},q[2]={0};
if(n<3)
return n;
for(i=0;i<n;i++)
{
for(j=0;j<n&&j!=i;j++)
{
temp=2;
p[0]=point[j].x-point[i].x;
p[1]=point[j].y-point[i].y;
for(k=0;k<n&&k!=j&&k!=i;k++)
{
q[0]=point[k].x-point[i].x;
q[1]=point[k].y-point[i].y;
if(judge(p,q))
temp++;
}
if(lineC<temp)
lineC=temp;
}
}
return lineC;
}
int judge(int *a,int *b)
{
int i,j,m,n;
i=a[0];
j=a[1];
m=b[0];
n=b[1];
if((i*n-j*m)==0)
return 1;
else
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator