#include<iostream>
#include<iterator>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
int main()
{
string a[5] = { "Jack_Ma","HuaTeng_Ma","QiangDong_Liu","YanHong_Li","Lei_Ding" };
vector <string> v(a, a + 5);//用數組初始化vector
vector <string> ::iterator i;//疊代器
i = find(v.begin(), v.end(),"Lei_Ding");
if (i == v.end()) cout << "沒找到" << endl;
else cout << "找到了" << endl;
cout << *i << " "; //可用指針
cout << *v.begin() << " ";
cout << i - v.begin() << endl; //索引位置
//下面的和上面效果一樣
// string * pStr=0; int i=-1;
// for (auto & item:v) //c++11文法
// {i++;if (item=="Lei_Ding") pStr=&item;}
// if(pStr==0) cout << "沒找到" << endl;
// else cout << "找到了" << endl;
// cout<<*pStr<< " ";
// cout << *v.begin() << " ";
// cout << i << endl; //索引位置
system("pause");
return 0;
}