home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / inrprod1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  851b  |  36 lines

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