Isn't this at least third thread about the same program/problem? Previously:
http://www.cplusplus.com/forum/beginner/200847/
http://www.cplusplus.com/forum/beginner/200939/
How should it go for, say 21 and 7?
Like this?
21 * 7 + 0 = 147
10 * 14 + 7 = 147
5 * 28 + 7 = 147
2 * 56 + 35 = 147
1 * 112 + 35 = 147 |
The 7 and 28 add up to 35.
On first row the "surplus" is 0.
On all other rows the surplus is initially same as the surplus on previous row, but if the first number was odd on the previous row, then we add the value of the second number from the previous row. Note too that the last line does not have surplus, even though 1%2==1.
In principle you do have all the necessary info within the vector 'halving' and the second loop.
Btw, what is the purpose of the line 37?
You, however, don't show such a table. Perhaps you would not show "35" either, but would prefer a "7+28"?