#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>

using namespace std;


int main(int argc, char * argv[])
{
    list<int> lst;

    lst.push_back(10);  //从链表尾部添加
    lst.push_front(20);  //从链表头部添加

    lst.insert(lst.begin(), 10, 1);  //从链表头开始lst.begin(),连续插入10个元素1;

    list<int>::iterator itor;  //迭代器
    for (itor = lst.begin(); itor != lst.end(); itor++) //遍历vector
    {
        lst.erase(itor);      //删除节点;
    }

    lst.pop_back();      //从尾部删除节点;
    lst.pop_front();      //从头部删除节点;

    system("pause");
    return 0;
}

 

相关文章:

  • 2021-09-09
  • 2022-12-23
  • 2022-01-22
  • 2021-08-10
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2021-04-13
  • 2022-12-23
  • 2021-11-08
  • 2021-04-24
  • 2021-07-06
  • 2021-05-23
  • 2021-09-12
相关资源
相似解决方案