题解 | 平分的直线

平分的直线

https://www.nowcoder.com/practice/e51af77572f74a5fa069b4d5a3a0953e

/*
struct Point {
    int x;
    int y;
    Point() :
            x(0), y(0) {
    }
    Point(int xx, int yy) {
        x = xx;
        y = yy;
    }
};*/
class Bipartition {
public:
    vector<double> getBipartition(vector<Point> A, vector<Point> B) {
        // write code here
        Point centerA = Point(A[0].x+ A[1].x +A[2].x + A[3].x, A[0].y+A[1].y + A[2].y+A[3].y);
        Point centerB = Point(B[0].x+ B[1].x +B[2].x + B[3].x, B[0].y+B[1].y + B[2].y+B[3].y);

      
        double k= (centerA.y - centerB.y +0.0) /(centerA.x -centerB.x);
        double b = (centerA.y  - centerA.x *k  )/4;
        return {k,b};


    }
};

全部评论

相关推荐

辅助位:定时器项目都被用烂了,感觉
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务