fork download
  1. #include <algorithm>
  2. #include <functional>
  3. #include <iostream>
  4. #include <iterator>
  5.  
  6. int main()
  7. {
  8. int a[] = {5, 6, 7, 8, 9};
  9. int b[] = {0, 3, 5, 2, 1};
  10. int c[5];
  11. std::transform (a, a + 5, b, c, std::minus<int>());
  12. std::copy(c, c + 5, std::ostream_iterator<int>(std::cout, ", "));
  13. }
  14.  
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
5, 3, 2, 6, 8,