I was given an assignment to develop an algorithm for dispensing stamps for a postage stamp vending machine. I need to write a function that will return the minimum number of stamps for a given value. We can assume that there will always be a one cent stamp in the machine.
The function prototype looks like:
int min_number_of_stamps (
const int* array, /* input array of sorted stamp values */
size_t array_size, /* number of elements in array */
int request /* desired value to of stamps */
);
The function will return the minimum number of stamps for a given
value. As an example, if the array was [90,30,24,15,12,10,5,3,2,1]
and the
request was 32
, the output should be 2
, one 30 cent stamp
and one 2
cent stamp
.
Could anyone help me solve this question or give me some hint to do it?