in reply to Problem in generating ids through Array

Homework problem, huh? No code.

You have the same number of outputs as inputs, which is a clue to the fact that you should be looping over the input. If you have an array of counters, one per level (0, 0, 0), then every time around the loop, the value tells you which level counter to increment. If the value decreases, zero the counter one level below. Then all you need to do is print out the level counters each time, ignoring any that are zero.

Does that help?