求一条直线经过一个直角坐标系里m个点最多点的点数

typedef struct 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 开始计算满足该直线方程的点的个数,与历史记录比较,记录大的,最后就得到最多的点数,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值