# include<iostream>
# include<list>
using namespace std;
bool myCompare(int v1,int v2)
{
//降序 第一个数大于第二个数
return v1 > v2;
}
void printList(const list<int>& L)
{
for (list<int>::const_iterator it = L.begin(); it != L.end(); it++)
{
cout << *it << " ";
}
cout << endl;
}
void test01()
{
//所有不支持随机访问迭代器的容器,不可以使用标准算法
//不支持随机访问迭代器的容器,内部会供应对应的一些算法
list<int>L1; //默认构造
L1.push_back(10);
L1.push_back(20);
L1.push_back(30);
L1.push_front(40);
L1.push_front(50);
printList(L1);
L1.reverse();
printList(L1);
L1.sort(myCompare);
printList(L1);
}
int main()
{
test01();
system("pause");
return 0;
}
07-09
1091

09-10
601

07-19
1214
