
Combination&&arrange in order
Quote:
> there is a program to show balls arrange in order, for example
5 balls should have 120 cases, but different colors ball should
combination,like 2 red color balls and 3 white color balls,
total 5 balls have 10 cases like: {11000, 10100, 10010, 10001,
01100, 01010, 01001, 00110, 00011, 00101} now I just can show
120 cases in different 5 colors ball,can't exclude same case in
cases Y_Y Is there any guys can give me a hand?Thanks!
[ Code deleted ]
-----------------------------------------------------------------
Since the code you posted doesn't work, this "help" is based on
what I THINK you're trying to do. It looks like you're trying to
use a FOR loop to select the object in the "i"th position by
stepping through the set, then making a recursive call to select
the object in the "i+1"th position. If your set consists of
groups of non-unique objects and you want to eliminate
permutations which only involve the "swapping" of positions
between objects of the same type, you simply have to make the
recursive call conditional upon the object just chosen being
either the first object selected for that position or the first
object of its type to be selected for that position.
Because you are using a FOR loop, the first condition is easily
determined; if it is the 1st iteration of the loop, the object is
the first of any type chosen for that position. The second
condition is also easy to determine IF one makes the assumption
that the objects of similar type are grouped together in the
array, that is that all objects of the same type are located in a
contiguous block. If this condition is true, then one can simply
check the type of object used in that position just prior to the
selection of the current element in order to determine if the
current selection is the first of its type to be chosen for that
position in the permutation.
-----------------------------------------------------------------
Derek Asari
Sent via Deja.com http://www.deja.com/
Before you buy.