fork download
  1. #include <iostream>
  2. #include <list>
  3. #include <iterator>
  4. #include <algorithm>
  5. #include <functional>
  6.  
  7. int main ( ) {
  8. std :: list < int > myList ( std :: istream_iterator < int > ( std :: cin ) , std :: istream_iterator < int > ( ) ) ;
  9. std :: list < int > resultList ;
  10. std :: copy_if ( myList.begin () , myList.end ( ) , std :: back_inserter ( resultList ) , std :: bind2nd ( std :: less < int > ( ) , 0 ) ) ;
  11. std :: copy ( resultList.begin ( ) , resultList.end ( ) , std :: ostream_iterator < int > ( std :: cout , " " ) ) ;
  12. std :: cout << std ::endl ;
  13. }
Success #stdin #stdout 0s 3476KB
stdin
-10 6 4 2 6 -4 2 9 -9
stdout
-10 -4 -9