2025年std--vector find_vectornator工具使用

std--vector find_vectornator工具使用vector 本身是没有 find 这一方法 其 find 是依靠 algorithm 来实现的 include include include int main using namespace std vector vec vec push back 1 vec push back 2 vec push back 3 vec


vector本身是没有find这一方法,其find是依靠algorithm来实现的。

#include 
#include
#include
int main()
{

using namespace std;
vector vec;
vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);
vec.push_back(5);
vec.push_back(6);

vector::iterator it = find(vec.begin(), vec.end(), 6);

if (it != vec.end())
cout<<*it< else
cout<<"can not find"<
return 0;
}
编程小号
上一篇 2025-02-10 11:57
下一篇 2025-03-01 13:21

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/124144.html