example223.cpp

来自「Data Abstraction & Problem Solving with 」· C++ 代码 · 共 31 行

CPP
31
字号
#include <list>#include <iostream>using namespace std;int main(){	list<int> myList;	list<int>::iterator curr;	// right now, the list is empty;	// start the iterator at the beginning of myList	curr = myList.begin();	// test for empty list	if (curr == myList.end())	   cout << "The list is empty" << endl;	// insert five items into the list myList	for (int j = 0; j < 5; j++)	   // places item j at the front of the list	   curr = myList.insert(curr, j);	// now output each item in the list starting with the	// first item in the list; keep moving the iterator	// to the next item in the list until the end of	// the list is reached	for (curr = myList.begin(); curr != myList.end(); curr++)	   cout << *curr << " ";	cout << endl;	return 0;}  // end main

⌨️ 快捷键说明

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