I have 2 vectors of ints.
say the first one has (2,1). and the second one (1,1).
I am trying to subtract numbers like this:
2 1 - 1 1 = 1 0
then I need to add these 2 numbers so the final answer would be 1.
I've tried a for loop, but it's subtracting each number from each element, instead of only the first one.
This is what I've tried so far.
vector<int> temp;
for(unsigned i =0; i < Vec1.size(); i++)
for(unsigned o =0; o < Vec2.size(); o++)
temp.push_back(Vec1.at(i).nums- Vec2.at(o).nums);
//where nums, are just the numbers showed above
The output as you would expect is : 1 1 0 0
and I need it to be:
1 0
then I can just do a for loop to add all the ints together.
Any help, would be greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire