⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p80.cpp

📁 代码中包含了部分作者侯捷的<<STL源码剖析>>一书中的程序实例,有助于理解及应用STL,来进行方便高效的编程
💻 CPP
字号:
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	const int arraySize=7;
	int ia[arraySize]={0,1,2,3,4,5,6};

	vector<int> ivect(ia,ia+arraySize);
	list<int> ilist(ia,ia+arraySize);
	//deque<int> ideque(ia,ia+arraySize);

	vector<int>::iterator it1=find(ivect.begin(),ivect.end(),4);
	if(it1==ivect.end())
		cout<<"4 not found."<<endl;
	else
		cout<<"4 found."<<*it1<<endl;

	list<int>::iterator it2=find(ilist.begin(),ilist.end(),8);
	if(it2==ilist.end())
		cout<<"8 not found."<<endl;
	else
		cout<<"8 found."<<*it2<<endl;

	/*
	deque<int>::iterator it3=find(ideque.begin(),ideque.end(),8);
	if(it3==ideque.end())
		cout<<"8 not found."<<endl;
	else
		cout<<"8 found."<<*it3<<endl;
    */
	return 0;
}

⌨️ 快捷键说明

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