已知一个点集vectorp和点集的大小n,点都在一个二维平面上且横坐标各不相同,找到一条穿过点数最多的直线,返回值为vector,代表所求直线的斜率和截距。
加载中...
import java.util.*; /* public class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } public Point() { this.x = 0; this.y = 0; } }*/ public class DenseLine { public double[] getLine(Point[] p, int n) { // write code here } }
/* struct Point { int x; int y; Point() : x(0), y(0) { } Point(int xx, int yy) { x = xx; y = yy; } };*/ class DenseLine { public: vector
getLine(vector
p, int n) { // write code here } };
# -*- coding:utf-8 -*- # class Point: # def __init__(self, a=0, b=0): # self.x = a # self.y = b class DenseLine: def getLine(self, p, n): # write code here
/* public class Point { public int x; public int y; public Point () { x = 0; y = 0; } public Point (int a, int b) { x = a; y = b; } }*/ class DenseLine { public double[] getLine(Point[] p, int n) { // write code here } }