📄 list_are.cpp
字号:
#ifdef __BCPLUSPLUS__
#include <list.h>
#else
#include <list>
#endif
#include <iostream>
using namespace std;
typedef list<int> LISTINT;
void main(void)
{
LISTINT listOne;
LISTINT listAnother;
LISTINT::iterator i;
// Add some data
listOne.push_front (2);
listOne.push_front (1);
listOne.push_back (3);
listAnother.push_front(4);
listAnother.assign(listOne.begin(), listOne.end());
// 1 2 3
for (i = listAnother.begin(); i != listAnother.end(); ++i)
cout << *i << " ";
cout << endl;
listAnother.assign(4, 1);
// 1 1 1 1
for (i = listAnother.begin(); i != listAnother.end(); ++i)
cout << *i << " ";
cout << endl;
listAnother.erase(listAnother.begin());
// 1 1 1
for (i = listAnother.begin(); i != listAnother.end(); ++i)
cout << *i << " ";
cout << endl;
listAnother.erase(listAnother.begin(), listAnother.end());
if (listAnother.empty())
cout << "All gone\n";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -