#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef struct point
{
int x,y;
} Point;
Point p[710];
int judge(int i,int j,int k)
{
if((p[k].y-p[j].y)*(p[j].x-p[i].x)==(p[j].y-p[i].y)*(p[k].x-p[j].x))
return 1;
else return 0;
}
int main()
{
//freopen("in.txt","r",stdin);
int cas,n,num,max;
char str[100];
scanf("%d",&cas);
getchar();
getchar();
while(cas--)
{
n=0;
num=0;
while(gets(str)!=NULL)
{
if(strcmp(str,"")==0)
break;
sscanf(str,"%d%d",&p[n].x,&p[n].y);
n++;
}
max=0;
for(int i=0; i<n; i++)
{
for(int j=i+1; j<n; j++)
{
num=2;
for( int k=j+1; k<n; k++)
{
if(judge(i,j,k))
num++;
}
max=max>num?max:num;
}
}
cout<<max<<endl;
if(cas)
cout<<endl;
}
return 0;
}
最近感觉越学越糊涂了,gets的读取问题上又晕了,gets是以回车符作为结束符的,所以在scanf读完cas后,用了两个getchar();然后就是这个题的思路,枚举吧,固定两个点,然后看其他点是否在这两点连成的直线上。