0

グラハムスキャンを使用して凸包の周囲を計算するプログラムを作成しており、データポイントのセットで最小の y 座標を見つける必要があります。struct でstd::min_element(vector.begin(), vector.end())オーバーロードされた演算子を使用しています。問題は、いくつかの点が同じ最低の y 座標を共有している可能性があることです。その場合、それらの点の x 値を使用してそれらを比較する必要があります。すべてをループすることなく、他のポイントが min_element と同じ y を共有しているかどうかを確認する簡単なチートはありますか?<point

構造体:

struct cord{
        cord():x(0),y(0){}
        int x,y;
        bool operator<(const cord &p) const { return y < p.y; }
};

typedef std::vector<cord>::iterator vecIter;

関数呼び出し:

vecIter lowestPoint =
                std::min_element(points.begin(), points.end());

std::cout << "the lowest point of the data set is: " << "(" <<
                lowestPoint->x << "," << lowestPoint->y << ")"  << std::endl;
4

1 に答える 1