#include <iostream> // cout #include <algorithm> // find #include <vector> // vector #include <typeinfo> using namespace std; int main () { // using find with array and pointer: int myints[] = { 10, 20, 30, 40 }; int * p; p = find (myints, myints+4, 30); //返回查找到的元素的物理地址 cout<<p<<" "; if (p != myints+4) cout << "Element found in myints: " << *p << ' '; else cout << "Element not found in myints "; // using find with vector and iterator: vector<int> myvector (myints,myints+4); vector<int>::iterator it; it = find (myvector.begin(), myvector.end(), 30); cout<<typeid(it).name()<<" "; if (it != myvector.end()) cout << "Element found in myvector: " << *it << ' '; else cout << "Element not found in myvector "; return 0; }