#include <list>
中没有find功能呀

解决方案 »

  1.   

    // alg_find.cpp
    // compile with: /EHsc 
    #include <list>
    #include <algorithm>
    #include <iostream>int main( )
    {
       using namespace std;   list <int> L;
       list <int>::iterator Iter;
       list <int>::iterator result;
       
       L.push_back( 40 );
       L.push_back( 20 );
       L.push_back( 10 );
       L.push_back( 40 );
       L.push_back( 10 );   cout << "L = ( " ;
       for ( Iter = L.begin( ) ; Iter != L.end( ) ; Iter++ )
          cout << *Iter << " ";
       cout << ")" << endl;
       
       result = find( L.begin( ), L.end( ), 10 );
       if  ( result == L.end( ) )
          cout << "There is no 10 in list L." << endl;
       else
          result++;
          cout << "There is a 10 in list L and it is"
               << " followed by a " << *(result) << "." << endl;
    }