POJ 1118 Lining Up

/*
【题目】POJ 1118 
【题意】判断多个点中最多有多少个点共线
【题解】按横纵坐标大小排序,从小到大遍历每一个点,
计算该点与剩余点的斜率,记录到数组中
在数组中查找有有多少个斜率相同的点
注意只有两个点的情况,应该输出2 

*/

#include
#include
#include 
#include
#include
using namespace std;
const int inf=0x3f3f3f;
struct Point{
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
};
Point a[1000];

typedef Point Vector;
Vector operator + (Vector A,Vector B){
	return Vector(A.x+B.x,A.y+B.y);
} 
Vector operator - (Vector A,Vector B){
	return Vector(A.x-B.x,A.y-B.y);
} 
Vector operator * (Vector A,double p){
	return Vector(A.x*p,A.y*p);
} 
Vector operator / (Vector A,double p){
	return Vector(A.x/p,A.y/p);
} 

bool operator < (const Point &a,const Point &b){
	if(a.x==b.x){
		return a.y>n;
		if(n==0){
			break;
		}
		for(int i=0;i>a[i].x>>a[i].y; 
		}
		sort(a,a+n);
		int ans=1;
		for(int i=0;i

 

你可能感兴趣的:(计算几何)