But the value is getting changed all the time, example: the value starts off at 0, first loop changes it to 1, 4th loop changes it to 5, 7th loop changes it to 9. How do I go from 9 to 5 without knowing its going to be 9 and 5?
So that works and makes x and y the previous value, but is it possible with this code to make it do that more than once? I've simplified the code but it basically searches an array for the counter and increments it if it finds the numbers already used, if the counter goes above 9, it goes to the last zero and changes that number to try and fix the problem and it should repeat this until it works. Problem is with my code it will only do it once since I can only save the previous zero and not the zeros before it. Any help?
In line 19 you didn't assign the value. You have used == . Is that a mistake due to your typing ? Why can't you use another integer array for storing zeros and a variable to count the number of zeros ?
I'd suggest you keep a vector of previous entries and provide an interface to access that data (or use vector iterators to do it).
For instance vector::push_back will allow you to add to the end of the vector and you can use an iterator to cycle backwards through the set of values in that vector. vector::back will give you the most recently 'assigned' value.
A nicer way of doing this would be to implement a wrapper to the vector that allows for operator= , prev , and next calls that hide all of the details.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...