当前位置:网站首页>45. [Application of list linked list]
45. [Application of list linked list]
2022-07-30 23:34:00 【Lee is struggling...】
[Insert a data in the header]
Function name.push_front()
[Insert a data at the end]
Function name.push_back()
【Multiple Insertion Data】
Function name.insert(function name.begin(),n) Where to start and who to insert
[Multiple Insertion Data 2]
Function name.insert(function name.begin(),n,m) Where to start, how many to insert, who to insert
[Insert using iterator]
iist
Object name=function name.begin();
Function name.insert(object name, number, element)
[Delete the first element]
Function name.pop_front()
[Remove last element]
Function name.pop_back()
【Multiple delete data】
function name 1.erase(function name 1.begin(), function name 1.end()
[Linked list traversal can only be iterator traversal]
iist
for(object name=function name.begin();object name!=end();object name++)
{
cout<<*object name;
}
#include
#include
using namespace std;
int main()
{
list
int s[4] = { 2,5,8 };
list
list_b.push_front(1); //Insert at the head
list_b.push_back(2); //Insert at the end
list_b.insert(list_b.begin(), 66); // where to insert, what to insert
list_b.insert(list_b.end(), 88);
list_b.insert(list_b.end(),3, 100); // where to insert, how many to insert, who to insert
list
it = list_b.begin();
it++;
list_b.insert(it, 5, 111);
list_b.insert(list_b.begin(), s, s + sizeof(s) / sizeof(int)); //insert a normal array
list_b.pop_front(); //delete the first one
list_b.pop_back(); //delete the last one
//list_b.erase(list_b.begin(), list_b.end()); // delete from the beginning
list
for (itor = list_b.begin(); itor!= list_b.end(); itor++)
{
cout << *itor << " ";
}
return 0;
}


边栏推荐
- Abstract classes and interfaces (study notes)
- 360核心安全大脑3.0正式发布,构建政企用户的“能力中枢平台”
- The problem of sticky packets in tcp protocol transmission
- 【VisDrone数据集】YOLOV3训练VisDrone数据集步骤与结果
- 测试人面试 常被问到的计算机网络题,高薪回答模板来了
- PS基础学习(一)
- 软件测试三阶段,你在哪一步?
- PyTorch模型导出到ONNX文件示例(LeNet-5)
- PyTorch model export to ONNX file example (LeNet-5)
- Soft Exam Summary
猜你喜欢
随机推荐
抽象类和接口(学习笔记)
47. 【Pointers and Arrays】
ZZULIOJ: 1120: the most value to exchange
测试人面试 常被问到的计算机网络题,高薪回答模板来了
实验8(vlan实验)
牛逼的公司都在用的绩效管理法OKR
uniapp folding box secondary loop
Shell脚本 if语句
Apache Doris系列之:深入认识实时分析型数据库Apache Doris
The first level must project independently
The difference between ?? and ??= and ?. and || in JS
智能创意中的尺寸拓展模块
写了多年业务代码,我发现了这11个门道,只有内行才知道
借助深度估计的点云场景重建
[动态规划] 0-1背包问题和完全背包问题
Calico 网络通信原理揭秘
DFS题单以及模板汇总
2D转换模块&&媒体查询
Chevrolet Trailblazer, the first choice for safety and warmth for your family travel
46.<list链表的举列>





![[0x800706D9] solution appears in Microsoft Store](/img/f2/7485cd55fd260220378acd485d8dc9.png)


