typedef struct POINT
{
double x;
double y;
}Point;
输入点数和各个点的坐标:
把坐标数组和数组的长度作为参数传入。
{
double x;
double y;
}Point;
输入点数和各个点的坐标:
void hjd_init_points()
{
printf("please input the number of points:\n");
int nM=0, nPos=0;
scanf("%d", &nM);
Point myPoints[nM];
for(nPos=0;nPos<nM;nPos++)
{
printf("\nplease input the No.%d point:(like x,y)\n", nPos);
scanf("%lf,%lf", &myPoints[nPos].x, &myPoints[nPos].y);
}
printf("\nComplete input the Points, and now to calculate the max number of points that a line can cross...\n");
int nMax=hjd_Get_Line_Cross_Points(myPoints, nM);
printf("\nThe max number of points that a line can cross = %d\n", nMax);
}
把坐标数组和数组的长度作为参数传入。
P0,P1,...,P(m-1)个点,从第一个点开始,依次求与后面某个点之间直线的方程,然后从 P0 开始计算满足该直线方程的点的个数,与历史记录比较,记录大的,最后就得到最多的点数,