samedi 27 mars 2021

Can someone tell me what's wrong with my cpp code?

I'm trying to return a vector from evenBodd function instead I get this - invalid operands to binary expression ('std::ostream' (aka 'int') and 'const char [2]'

I'm new to cpp so any help would be appreciated.

Code:

vector<int> eveBodd(vector<int> arr){
vector<int> even, odd;
for(int i=0; i<arr.size(); ++i){
    if(arr[i]%2 == 0){
        even.push_back(arr[i]);
    }
    else{
        odd.push_back(arr[i]);
    }
}
even.insert(even.end(), odd.begin(), odd.end());
return even;
}


int main() {
vector<int> arr{1,2,3,4,5,6,7,8,10};
cout << eveBodd(arr) << "\n";
return 0;
}

Code Image Code

Aucun commentaire:

Enregistrer un commentaire