fork download
  1. #include <iostream>
  2. #include <numeric>
  3. #include <vector>
  4. #include <iterator>
  5.  
  6. int func ( int x , int y )
  7. {
  8. return ( (y > 0) && (y % 2 == 0) )?x*y:x ;
  9. }
  10.  
  11. int main() {
  12. std::vector<int> vec ( (std::istream_iterator<int>(std::cin)) , std::istream_iterator<int>() ) ;
  13. std::cout << std::accumulate ( vec.begin() , vec.end() , 1 , func ) << std::endl ;
  14. }
  15.  
  16.  
Success #stdin #stdout 0s 2864KB
stdin
1 2 3 4 5 6 7 8 9 0
stdout
384