fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector<int> v = {1,2,3,4,5,6,7,8,9,10};
  7. int even =0, odd=0;
  8. for(auto it = v.begin(); it!=v.end();it++){
  9. if(*it%2==0){
  10. even+=*it;
  11. }
  12. else{
  13. odd+=*it;
  14. }
  15. }
  16. cout << "EVEN: "<< even<<endl;
  17. cout << "ODD: " << odd<<endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
EVEN: 30
ODD: 25