//判断共线的最大点数有多少个?!根据斜率判断,为避免斜率不存在的情况,改为乘法比较简单一点!
#include <iostream>
#include <climits>
using namespace std;
struct Info
{
int x;
int y;
}cor[705];
int main()
{
int n, i, j, k, ans, max;
double k1, k2;
while (cin >> n)
{
if (n == 0) break;
ans = 0;
max = 0;
for (i = 1; i <= n; i++)
cin >> cor[i].x >> cor[i].y;
for (i = 1; i <= n; i++)
{
for (j = i+1; j <= n; j++)
{
max = 0;
for (k = j+1; k <= n; k++)
{
if ((cor[j].x - cor[i].x)*(cor[k].y - cor[j].y) == (cor[j].y - cor[i].y)*(cor[k].x - cor[j].x))
max++;
}
if (max > ans)
ans = max;
}
}
cout << ans + 2<< endl;
}
system("pause");
}
poj 1118 Lining Up
最新推荐文章于 2019-07-14 07:24:18 发布