home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / test / regression / nthelem2.cpp < prev    next >
C/C++ Source or Header  |  2002-04-29  |  801b  |  35 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <vector>
  5. #include <functional>
  6. #include <algorithm>
  7. #include <cstdlib>
  8. #include <iostream>
  9. #include <iterator>
  10.  
  11. #ifdef MAIN 
  12. #define nthelem2_test main
  13. #endif
  14.  
  15. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  16. using namespace std;
  17. #endif
  18. int nthelem2_test(int, char**)
  19. {
  20.   cout<<"Results of nthelem2_test:"<<endl;
  21.   vector <int> v1(10);
  22.   for(int i = 0; i < v1.size(); i++)
  23.     v1[i] = rand() % 10;
  24.   ostream_iterator<int> iter(cout, " ");
  25.   copy(v1.begin(), v1.end(), iter);
  26.   cout << endl;
  27.   nth_element(v1.begin(),
  28.                v1.begin() + v1.size() / 2,
  29.                v1.end(),
  30.                greater<int>());
  31.   copy(v1.begin(), v1.end(), iter);
  32.   cout << endl;
  33.   return 0;
  34. }
  35.