#include<algorithm>
#include<vector>
using namespacestd;
vector<int>array(100);//整型的array數組
int main()
{
array[20]=50;
vector<int>::iterators=find(array.begin(),array.end(),50);第一個參數是array的起始地址,第二個參數是array的結束地址,第三個參數是需要查找的值
if( s!=array.end())//找到
cout<<*s<<endl;
elsecout<<"notfind!"<<endl;
system("pause");
return0;
}
find()函數的定義:
template <class InputIterator, classT>InputIterator find( InputIterator first, InputIterator last, const T&value){ while (first != last && *first !=value)++first; return first; }