|
学习了std::find()函数使用方法,转自http://blog.csdn.net/zhangweijiqn/article/details/9107571
这里做个笔记。
#
include
<iostream>
#
include
<vector>
#
include
<algorithm>
//注意要包含该头文件
using
namespace
std;
int
main()
{
int
nums[] = {
3
,
1
,
4
,
1
,
5
,
9
};
int
num_to_find =
5
;
int
start =
0
;
int
end =
5
;
int
* result = find( nums + start, nums + end, num_to_find );
if
( result == nums + end )
{
cout<<
"Did not find any number matching "
<< num_to_find << endl;
}
else
{
cout<<
"Found a matching number: "
<< *result << endl;
}
return
0
;
}
例二,在容器中查找:
|