C++ Primer 11.1

来源:互联网 发布:unity3d导航网格寻路 编辑:程序博客网 时间:2024/06/08 13:13
[root@localhost testc++]# vi 9_00.cc

1 #include <iostream>
2 #include <list>
3 #include <vector>
4 #include <string>
5 using namespace std;
6
7 int main()
8 {
9 int search_value = 42;
10 int a[6]= {2,44,32,54,42,11};
11 vector<int> ivec(a,a+6);
12 vector<int>::const_iterator result = find(ivec.begin(),ivec.end(),search_value);
13 cout << "The value " << search_value << ( result == ivec.end()? " is not present " : " is present") <<endl;
14 return 0;
15 }
16

[root@localhost testc++]# g++ 9_00.cc
[root@localhost testc++]# ./a.out
The value 42 is present
[root@localhost testc++]#

原创粉丝点击