#include<iostream>
#include<list>
using namespace std;
class edge {
public:
edge(int weight){m_weight = weight;}
int m_weight;
};
bool compare(edge a,edge b) {
return a.m_weight > b.m_weight;
}
int main() {
list<edge> edges;
edge a(1);
edge b(3);
edge c(2);
edges.push_back(a);
edges.push_back(b);
edges.push_back(c);
edges.sort(compare);
list<edge>::iterator comIte = edges.begin();
for(;comIte != edges.end();comIte++)
{
printf("%d,\n", comIte->m_weight);
}
system("pause");
return 0;
}
stl list排序
最新推荐文章于 2023-09-27 08:00:00 发布