/*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称 :
*作 者 : 田志伟
*完成日期 : 2016年6月1号
*版 本 号 : v1.0
*问题描述 :阅读程序
*输入描述 :
*程序输出 :
*/
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
int ia[5] = {1,2,3,4};
list<int> id(ia, ia+4);
ostream_iterator<int> outite(cout, " ");
copy(id.begin(), id.end(), outite);
cout << endl;
copy(ia+1, ia+2, front_inserter(id));
copy(id.begin(), id.end(), outite);
cout << endl;
copy(ia+3, ia+4, back_inserter(id));
copy(id.begin(), id.end(), outite);
cout << endl;
list<int>::iterator ite = find(id.begin(), id.end(), 3);
copy(ia+0, ia+2, inserter(id, ite));
copy(id.begin(), id.end(), outite);
cout << endl;
copy(id.rbegin(), id.rend(), outite);
cout << endl;
return 0;
}程序运行:
辅助解释:
待后补充,暂时未知
本文通过一个具体的C++程序示例介绍了如何使用列表容器进行数据的插入、复制及查找等操作,并展示了如何利用迭代器来遍历列表。
790

被折叠的 条评论
为什么被折叠?



