顺序容器1

#include<iostream>
#include<list>
#include<deque>
using namespace std;
template<class T>
void printContainer(const char* msg,const T& s){
cout<<msg<<":";
copy(s.begin(),s.end(),ostream_iterator<int>(cout," "));
cout<<endl;
}
int main()
{
deque<int>s;
for(int i=0;i<10;i++){
int x;
cin>>x;
s.push_front(x);
}
printContainer("deque at first",s);
list<int>l(s.rbegin(),s.rend());
printContainer("list at first",l);
list<int>::iterator iter=l.begin();
while(iter !=l.end()){
int v=* iter;
iter=l.erase(iter);
l.insert(++iter,v);
}
printContainer("deque at last",s);
return 0;
}

posted @ 2023-04-26 21:18  不会JAVA的小袁  阅读(10)  评论(0编辑  收藏  举报