#include <iostream>
#include <vector>
using namespace std;
bool findInt(vector<int>::iterator beg, vector<int>::iterator end, int ival);
int main()
{
vector<int> a;
a.push_back(5);
a.push_back(10);
a.push_back(20);
vector<int>::iterator k = a.end();
k--;
bool 结果 = findInt(a.begin(), k, 20);//范围包括a.begin()但是不包括k,
if (结果 == true)
cout << "找到" << endl;
else
cout << "没有找到" << endl;
return 0;
}
bool findInt(vector<int>::iterator beg, vector<int>::iterator end, int ival)
{
while (beg != end)
{
if (*beg == ival)
break;
else
++beg;
}
if (beg != end)
return true;
else
return false;
}
迭代器
最新推荐文章于 2016-03-14 21:03:40 发布