Hi,I am really glad someone has responded to my thread.I really appreciate it. The problem is I have not started in typing out the source code because I still couldn't find a way to solve it. I am still overwhelm by two factor:
1) The total is being first specified by the user. This can be any number which I find it is 'Infinite' numbers for me to cater to.
2) Subtraction ranging from 1 to N. The N can be any number which is in the sense 'Infinite' numbers.
The book is really good in teaching C++ to newbie because of its simple explanation & exercises to apply what readers have learned from the book
to help improve their programming skill.However, it somehow lack answers for the exercises provided.
I have thought initially that maybe if I have a deep understanding of the previous example I could solve this exercise. I believe the preview coding which I have shown works because it always eliminates the remainder of the total number given by the user. So in anyway, even if the user randomly subtract the total, the logic is always to elminate the remainder by checking with %3.
For example, let say the user provides a total of 10.
11%3 will give a remainder of two. So I will subtract two from it forcing it to be a multiplication of 3.
Therefore,the total now is 9.
Next,let say the user subtracts 1.
The total is 8.
8%3 will give a remainder of two.I will then subtract two from it forcing it to be a multiplication of 3.
The total is 6.
.
.
.
So do you see the pattern now?
The program is designed that it will meet its target of reaching 3 to win the game.Why so?
This I believe is also due to the program having the chance to start first in subtracting.
Hence, whenever it reaches 3, the user will subtract and the computer will win the game by subtracting
whatever is left.
Yup,but I still can't figure out the exercise though.
Do you have any idea of solving it?![]()





Reply With Quote
Bookmarks