#include<bits/stdc++.h>
#include<list>//必须应用list头文件
#include<vector>
using namespace std;
int main() {
list<int> l;
list<int>::iterator it=l.begin();
for(int i=1; i<100; i++) {
l.push_back(i);//尾插
// l.push_front(i);//头插
}
l.push_back(99);
// vector<int> v{6, 6};//创建一个vector容器,里面有6个6
// l.insert(it,v.begin(), v.end());插入6个6
// l.remove(2); // 删除容器当中值为2的元素
/*l.sort();// 排序
for(auto e:l) {
cout<<e<<" ";
}
l.unique();// 去除连续重复的元素*/
for(auto e:l) {
cout<<e<<" ";
}//正向迭代器
return 0;
}
全部回复 共 0 条
还没有人回复。往下写第一条。
发表回复
登录后即可回复本帖,与出题人和同学一起讨论。
登录