funcmaxPoints(points [][]int) int { n :=len(points)if n <=2 {return n } res :=0for i :=0; i < n; i++ { m :=make(map[string]int) // 用于存储每个斜率对应的点的个数 dup :=1// 用于记录与当前点重合的点的个数for j := i +1; j < n; j++ { x, y := points[j][0], points[j][1]if x == points[i][0] && y == points[i][1] { // 如果当前点与当前枚举的点重合,则将 dup 加 1 dup++continue } g := gcd(x-points[i][0], y-points[i][1]) // 计算两个点之间的最大公约数 dx, dy := (x-points[i][0])/g, (y-points[i][1])/g // 计算斜率 m[itoa(dx, dy)]++// 将斜率相同的点分为一组,统计每组中点的个数 }// 更新最大值 res =max(res, dup)for _, v :=range m { res =max(res, v+dup) } }return res}funcitoa(a, b int) string {if a ==0 {return"0" }if b ==0 {return"1" }if a <0 { a, b =-a, -b }return strconv.Itoa(a) +"/"+ strconv.Itoa(b)}funcgcd(a, b int) int {for a !=0 { a, b = b%a, a }return b}funcmax(a, b int) int {if a > b {return a }return b}