link
#include#include #include #include using namespace std; typedef struct Point{ int x; int y; }point; bool cmp(point p1, point p2){ return p1.x < p2.x; } int main(){ vector p; point pp1, pp2; pp1.x = 100; pp1.y = 2; pp2.x = 30; pp2.y = 4; p.push_back(pp1); p.push_back(pp2); sort(p.begin(), p.end(), cmp); //vector ::iterator it = p.begin(); //cout << (*it).x << ' ' << (*it).y << ' ' << endl; for(vector ::iterator it = p.begin(); it!=p.end(); it++) { //cout<<"迭代遍历:"<<(*it).x< 迭代遍历:30 4 迭代遍历:100 2欢迎分享,转载请注明来源:内存溢出
评论列表(0条)