home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl2vac.zip / STLport-4_5_3.zip / STLport-4.5.3 / test / regression / nthelem1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  748b  |  33 lines

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