41 lines
883 B
C++
41 lines
883 B
C++
/*************************************************************************
|
|
> File Name: stl_list.cpp
|
|
> Author: SongTL
|
|
> Mail: songtianlun@comleader.com.cn
|
|
> Created Time: 2020年07月21日 星期二 17时37分59秒
|
|
************************************************************************/
|
|
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <numeric>
|
|
#include <algorithm>
|
|
|
|
using namespace std;
|
|
|
|
typedef list<int> LISTINT;
|
|
typedef list<char> LISTCHAR;
|
|
|
|
int main()
|
|
{
|
|
LISTINT listOne;
|
|
LISTINT::interator i;
|
|
|
|
listOne.push_front(2);
|
|
listOne.push_front(1);
|
|
|
|
listOne.push_back(3);
|
|
listOne.push_back(4);
|
|
|
|
cout << "listOne.begin() --- listOne.end():" <<endl;
|
|
for(i = listOne.begin(); i != listOne.end(); ++i)
|
|
cout << *i << " ";
|
|
cout << endl;
|
|
|
|
LISTINT::reverse_interator ir;
|
|
for(ir = listOne.rbegin(); ir != listOne.rend();ir++)
|
|
cout << *ir << " ";
|
|
cout << endl;
|
|
|
|
return 1;
|
|
}
|