#include<iostream>
#include<opencv2/opencv.hpp>
#include<vector>
using namespace cv;
using namespace std;
//对点的坐标按x从小到大排序,若x值相同则按y从小到大排序
bool compareValue(const Point& pt1, const Point& pt2)
{
if (pt1.x != pt2.x)
return pt1.x < pt2.x;
else
return pt1.y < pt2.y;
}
int main()
{
vector<Point> pt;
pt.push_back(Point(3, 3));
pt.push_back(Point(2, 2));
cout << pt[0] << pt[1] << endl;
std::sort(pt.begin(), pt.end(), compareValue);
cout << pt[0] << pt[1] << endl;
return 0;
}
c++之使用std::sort对坐标进行排序
最新推荐文章于 2024-05-27 21:38:22 发布