[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++]#
C++ Primer 11.1
最新推荐文章于 2022-12-06 10:10:57 发布