这个也是直接贴代码吧,比较简单
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::string str1 = "hello";
std::vector<std::string> svec;
svec.push_back("Hello");
svec.push_back("World");
svec.push_back("Baidu");
svec.push_back("Study");
svec.push_back("Hard");
std::vector<std::string>::iterator iter;
for(iter = svec.begin(); iter != svec.end(); ++ iter)
if(*iter == str1)
break;
iter = find(svec.begin(), svec.end(), str1);
if(iter != svec.end())
std::cout << "Yes" << std::endl;
else
std::cout << "No" << std::endl;
return 0;
}