如果某些strings
出现多次,我不能return
。返回字符串函数
即我有两个vectors
和我搜索了1st
vector
与2nd
vector
,如果一些elements
从2nd vector
在1st vector
出现不止一次,我想return
一个错误,但由于某种原因,我只能return
如果在1st vector
的元素不会出现不止一次
我的代码如下
我想return s1
当元素已经出现不止一次我该怎么办,我试图让它盈Ø F中的break
,但没有奏效
std::vector<std::string> test; //vector that comes in
test.push_back("YES");
test.push_back("YES");
//test.push_back("NO");
test.push_back("NO");
std::vector<std::string> test1; // vector from DB..
test1.push_back("YES");
test1.push_back("NO");
std::string s ("Element count is fine");
std::string s1 ("Element count is incorrect");
for(int i = 0; i < test1.size(); i++)
{
if(count(test.begin(), test.end(),test1[i]) > 1)
{
return s1;
}
}
return s;
请在某处添加一些fullstops。 – PermanentGuest 2012-03-14 12:25:25
看看你的休息时间。它存在forloop,而不是if语句。 – RvdK 2012-03-14 12:27:26
“我试着让它在盈亏的前面,但是没有奏效”=>究竟发生了什么? – PermanentGuest 2012-03-14 12:32:24