#include <bits/stdc++.h> using namespace std; int main(){ list<int> a; int b[] = {1,2,3,4}; list<int> c(b,b+sizeof(b)/sizeof(int)); a.insert(a.begin(),c.begin(),c.end()); a.insert(a.begin(),3,1); //在容器首位添加元素 a.push_front(0); //在容器末位添加元素 a.push_back(5); cout<<"一:"<<a.front()<<endl; cout<<"末:"<<a.back()<<endl; //删除首位元素 a.pop_front(); a.sort(); a.unique(); cout<<"c:"<<c.size()<<endl; a.splice(a.begin(),c); cout<<"c:"<<c.size()<<endl; a.sort(); int b2[] = {7,8,9,10}; list<int> c2(b2,b2+sizeof(b2)/sizeof(int)); cout<<"c2:"<<c2.size()<<endl; a.merge(c2); cout<<"c2:"<<c2.size()<<endl; a.reverse(); for(list<int>::iterator i = a.begin();i!=a.end();i++){ cout<<*i<<" "; } return 0; }
标签:begin,cout,int,111,b2,sizeof From: https://www.cnblogs.com/wangyihang-xh/p/17937233