I use the Two-point - form
(y-y1)/(y2-y1)=(x-x1)/(x2-x1) change into the Generation form Ax+By+C=0.I'm sure the derivation is correct.But I always got wrong answer
![:(](./images/smilies/icon_frown.gif)
Everyone give me a hand,I need help.
Thanks in advance!
Code: Select all
#include <stdio.h>
#include <string.h>
#include <ctype.h>
typedef struct NODE
{
int x,y;
};
NODE a[1024]={0};
int cas,n,maxs;
char s[64]={'\0'};
int main()
{
int k,len,tmp,first,A,B,C;
scanf("%d\n",&cas);
for(int t=0;t<cas;t++)
{
n=0;
maxs=1;
while(gets(s)!=NULL)
{
if(!isdigit(s[0])) break;
len=strlen(s);
first=1; k=0;
for(int i=0;i<=len;i++)
if(isdigit(s[i]))
k=k*10+s[i]-'0';
else
{
if(first) a[n].x=k;
else a[n].y=k;
first=k=0;
}
n++;
}
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
{
tmp=0;
A=a[i].y-a[j].y;
B=a[j].x-a[i].x;
C=a[i].x*a[j].y-a[j].x*a[i].y;
for(int k=0;k<n;k++)
if(A*a[k].x+B*a[k].y+C==0)
tmp++;
if(maxs<tmp) maxs=tmp;
}
if(t) printf("\n");
printf("%d\n",maxs);
}
return 0;
}