// vector_test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int _tmain()
{
vector <int> vecIntegerArray;
vecIntegerArray.push_back(50);
vecIntegerArray.push_back(222);
vecIntegerArray.push_back(3);
vecIntegerArray.push_back(44);
cout<< "the contents of the vector are: " << endl;
vector <int>::iterator iArrayWalker = vecIntegerArray.begin();
while(iArrayWalker != vecIntegerArray.end())
{
cout << *iArrayWalker << endl;
iArrayWalker++;
}
vector <int>::iterator iElement = find(vecIntegerArray.begin(),
vecIntegerArray.end(),3);
if( iElement != vecIntegerArray.end() )
{
int nPosition = distance(vecIntegerArray.begin(),iElement);
cout << "Value "<< *iElement;
cout <<" find in the vector at position: " <<nPosition + 1 <<endl;
}
getchar();
return 0 ;
}