给定两个vecotrA和B,分别代表平面上两个正方形的四个顶点。已知正方形上下两条边与x轴平行,请找出一条直线,能够平分这两个正方形,返回值为vector,代表所求直线的斜率和截距,注意保证斜率存在。 测试样例: [(0,0),(0,1),(1,1),(1,0)],[(1,0),(1,1),(2,0),(2,1)] 返回:[0.0,0.5]
加载中...
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 Bipartition { public double[] getBipartition(Point[] A, Point[] B) { // write code here } }
/* struct Point { int x; int y; Point() : x(0), y(0) { } Point(int xx, int yy) { x = xx; y = yy; } };*/ class Bipartition { public: vector
getBipartition(vector
A, vector
B) { // write code here } };
# -*- coding:utf-8 -*- # class Point: # def __init__(self, a=0, b=0): # self.x = a # self.y = b class Bipartition: def getBipartition(self, A, B): # 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 Bipartition { public double[] getBipartition(Point[] A, Point[] B) { // write code here } }