c++ vector怎么查找某个元素是否存在

时间:2014-09-12 17:10:24   收藏:0   阅读:630

http://blog.csdn.net/pipisorry/article/details/39231949

自己编写一个find查找函数:

static bool find(vector<int> bn_vec, int an){
	for(vector<int>::iterator bn_vec_it = bn_vec.begin(); bn_vec_it != bn_vec.end(); bn_vec_it++){
		if( *bn_vec_it == an )
			return true;
	}
	return false;
}

vector<int> bn_vec;
bn_vec.push_back(2);
//...
int an = 1;

while( find(bn_vec, ++an) );


from:http://blog.csdn.net/pipisorry/article/details/39231949


原文:http://blog.csdn.net/pipisorry/article/details/39231949

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!