⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.cpp

📁 Vc.Net入门与提高源码
💻 CPP
字号:
#include <list>
#include <iostream>
using namespace std ;
typedef list<int> LISTINT;
int main()
{
    int rgTest1[] = {5,6,7};
    int rgTest2[] = {10,11,12};
    LISTINT listInt;
    LISTINT listAnother;
    LISTINT::iterator i;
    // 一次插入一个数
    listInt.insert (listInt.begin(), 2);
    listInt.insert (listInt.begin(), 1);
    listInt.insert (listInt.end(), 3);
    // 1 2 3
    cout << "lintInt:";
    for (i = listInt.begin(); i != listInt.end(); i++)
        cout << " " << *i;
    cout << endl;
    // 插入三个4
    listInt.insert (listInt.end(), 3, 4);
    // 1 2 3 4 4 4
    cout << "lintInt:";
    for (i = listInt.begin(); i != listInt.end(); ++i)
        cout << " " << *i;
    cout << endl;
    //插入一个空的数组
    listInt.insert (listInt.end(), rgTest1, rgTest1 + 3);
    // 1 2 3 4 4 4 5 6 7
    cout << "lintInt:";
    for (i = listInt.begin(); i != listInt.end(); ++i)
        cout << " " << *i;
    cout << endl;
    // 插入另外一个 LISTINT
    listAnother.insert (listAnother.begin(), rgTest2, rgTest2+3);
    listInt.insert (listInt.end(), listAnother.begin(), listAnother.end());
    // 1 2 3 4 4 4 5 6 7 10 11 12
    cout << "lintInt:";
    for (i = listInt.begin(); i != listInt.end(); ++i)
        cout << " " << *i;
    cout << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -