1.通用std::find 函数
例子1:
1 // find example 2 #include <iostream> 3 #include <algorithm> 4 #include <vector> 5 usingnamespacestd; 6 7 intmain () { 8 intmyints[] = { 10, 20, 30 ,40 }; 9 int* p; 10 11 // pointer to array element: 12 p = find(myints,myints+4,30); 13 ++p; 14 cout << "The element following 30 is " << *p << endl; 15 16 vector<int> myvector (myints,myints+4); 17 vector<int>::iterator it; 18 19 // iterator to vector element: 20 it = find (myvector.begin(), myvector.end(), 30); 21 ++it; 22 cout << "The element following 30 is " << *it << endl; 23 24 return0; 25 }