Count between arrays

I have a code that works like this:

When the user does X in this game, we count Y of the player (Y = random number)

Y is stored in a variable, e.g. it can store as this: 10, 15, 20 and so on.

I want to get all of the datas from this variable but since when it increases, it will store max 2 numbers (e.g. 50) at the time, I would want to store 10, 15, 20 separated in each variable so I can use them in next X.

So how would I cache Y in each variables? Is it possible to loop with for ( loop ) and loop all those Y numbers, and by that they're all cached? I'm not into for loops and therefore it's a question too. Thanks.. probably hard to understand, but ask if you cannot.
If you want to cache the last <n> values of Y, you're going to need to create an array or vector to store them in.

vector<int> cache_y;

int new_y = 15;
cache_y.push_back (new_y);

You're probably going to want to prune the cache so it doesn't grow indefinately.

What are you going to do with the values once you've cached them?
Topic archived. No new replies allowed.