编写一个循环将list容器的元素逆序输出

《c++ primer》P270,习题9.9

实现代码如下:

#include<iostream>
#include<list>
using namespace std;

int main()
{
	int ia[5]={1 , 2 , 3 , 4 , 5};
	list<int> lst1(ia , ia + 5);
	list<int>::iterator iter1 = lst1.begin(),
		iter2 = lst1.end();

	while(iter2 != iter1)
		cout<<*(--iter2)<<" " ;
	cout<<endl;

	return 0;
}
原文地址:https://www.cnblogs.com/heyonggang/p/3228005.html