#include<iostream>
#include<list>
using namespace std;
struct camerafoucs
{
int index;
int value;
bool operator<(camerafoucs b)
{
return value<b.value;
}
};
int main()
{
camerafoucs foucsvalue[10] = {{0,10},{1,23},{2,21},{3,9},{4,50},{5,43},{6,8},{7,13},{8,17},{9,6}};
list<camerafoucs> foucslist;
for(int i=0; i<10; i++)
{
foucslist.push_back(foucsvalue[i]);
}
foucslist.sort();
list<camerafoucs>::iterator i;
for (i=foucslist.begin(); i!=foucslist.end(); ++i)
{
cout<<static_cast<camerafoucs>(*i).value<<" ";
}
cout<<endl;
return 1;
}
list结构体根据某个成员进行排序
最新推荐文章于 2024-10-07 13:59:56 发布