import java.util.*;
/*
* public class Point {
* int x;
* int y;
* }
*/
public class Solution {
/**
*
* @param points Point类一维数组
* @return int整型
*/
public int maxPoints (Point[] points) {
// write code here
if(points == null|| points.length == 0){
return 0;
}
if(points.length == 1 || points.length == 2){
return points.length;
}
int res = 0;
for(int i = 0 ; i < points.length - 1; ++i){
int a = points[i].x;
int b = points[i].y;
for(int j = i + 1; j < points.length; ++j){
int aa = points[j].x - a;
int bb = points[j].y - b;
int count = 0;
if(aa == 0 && bb == 0){ //遇到重复的点,count+1
for(int k = 0; k < points.length; ++k){
if(points[k].x == a && points[k].y == b){
count++;
}
}
}else{ //不重复的点,则判断斜率,斜率相同count+1(这里把斜率除法巧妙地转化成乘法)
for(int k = 0; k < points.length; ++k){
if((points[k].x - a)*bb == (points[k].y - b) * aa){
count++;
}
}
}
res = Math.max(res, count);
}
}
return res;
}
}