fork download
  1. #include <vector>
  2.  
  3. #include <iostream>
  4.  
  5. #include <algorithm>
  6.  
  7. #include <functional>
  8.  
  9. using namespace std;
  10.  
  11. int
  12. Mul (int &_Left)
  13. {
  14.  
  15. if (_Left <= 3)
  16.  
  17. return 2 * _Left;
  18.  
  19. else
  20.  
  21. return 6;
  22.  
  23. }
  24.  
  25. int
  26. main ()
  27. {
  28.  
  29. int mynumbers[] = { 8, 9, 7, 2, 4, 1 };
  30.  
  31. vector < int >v1 (mynumbers, mynumbers + 6);
  32.  
  33. vector < int >v2 (7);
  34.  
  35. transform (v1.begin (), v1.end (), v2.begin (), ptr_fun (Mul)); //LINE I
  36.  
  37. vector < int >::iterator it = find_if (v2.begin (), v2.end (), bind2nd (equal_to < int >(), 4)); // LINE II
  38.  
  39. cout << *it << endl; // LINE III
  40.  
  41. return 0;
  42.  
  43. }
  44.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
4