一道简单的C++ 大家帮我看看哪错了 我很困惑

来源:百度知道 编辑:UC知道 时间:2024/07/04 15:08:21
题是这样的。
Description

“我该怎么办?”飞行员klux向你求助。
事实上,klux面对的是一个很简单的问题,但是他实在太菜了。
klux要想轰炸某个区域内的一些地方,它们是位于平面上的一些点,但是(显然地)klux遇到了抵抗,所以klux只能飞一次,而且由于飞机比较破,一点起飞就只能沿直线飞行,无法转弯。现在他想一次轰炸最多的地方。 不限定起飞地点

Input

第一行 n(1以下n行每行有一对整数,表示一个点的坐标。没有一个点会出现两次。

Output

一个整数,表示一条直线能覆盖的最多的点数。

Sample Input

5
1 1
2 2
3 3
9 10
10 11
我的代码是这样的:
我不知道我的为什么实现不了 请给于指点。
#include <iostream>
using namespace std;
void Boom(int a);
int main()
{int a,i,j;
float b[200][2];
cin>>a;

for (i=0;i<a;i++)
{for(j=0;j<2;j++)
{cin>>b[i][j];}}
Boom(a);
return 0;
}

void Boom(int x)// 计算斜率
{int i,j,y,t=0;
float b[200][2];
double x1,x2;
for(i=0;i<x-1;i++)
{for(j=1;j<x-i;j++)
{x1=b[i][1]/b[i][2];
x2=b[i+j][1]/b[i+j][2];// 如果斜率相等 则t+1
if (x1==x2)
{t++;

你的代码要改的地方太多
给你重写了个
#include <iostream>
using namespace std;
class Point;
istream& operator>>(istream& in,Point& p);
ostream& operator<<(ostream& out,Point& p);
class Point
{
private:
float x;
float y;
public: //坐标

float getSlope(); //斜率
friend istream& operator>>(istream& in,Point& p);
friend ostream& operator<<(ostream& out,Point& p);
};
float Point::getSlope() //返回该点斜率
{
return x/y;
}
istream& operator>>(istream& in,Point& p)
{
in >>p.x >>p.y;
return in;
}
ostream& operator<<(ostream& out,Point& p)
{
out <<p.x <<" " <<p.y <<endl;
return out;
}

int main()
{
int n=0,i;
cin>>n;
Point* p=new Point[n]; //创建n个元素的Point数组
float* Slope=new float[n]; //同上
int* Count=new int[n]; /