0

I am making a c++ program and i need a function that does the following:

IF u have an n (e.g: 4) digit number (IN THE FORM OF AN ARRAY) , each digit can take the vlaue from 0 to m (e.g: 5) and can exist more than once in the number (EACH DIGIT IS AN ELEMENT IN THE ARRAY)..

The number starts by the minimum value that the digits can form...

The number enters in a loop which increases the number, every iteration, to generate the NEXT BIGGER number that consists of the same digits and prints the number...

NOTE::: I dont want the function to increase the number every time by ONE and checks that the digits are there.... this will be silly :p...

I asked this question to find the fastest algorithm ....

Thanks in advance :)