Advertisement
ewelina_r

ex28

Jun 21st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<vector>
  2.  
  3. using namespace std;
  4.  
  5. template<class T>
  6. void costamol( vector<T>& result , const vector<T>& source, const T& key)
  7. {
  8.     for(typename vector<T>::const_iterator i=source.begin(); i!=source.end(); i++)
  9.     {
  10.         if((*i)<key)
  11.             result.push_back(*i);
  12.     }
  13. }
  14.  
  15. int main()
  16. {
  17.     vector<int> a;
  18.     vector<int> b;
  19.     a.push_back(1);
  20.     a.push_back(6);
  21.     a.push_back(8);
  22.     costamol<int>(b,a,4);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement