combinations of a string ?

M

M a n i s h

i have been trying to build a program to find various combinations of a string.
the problem is that if there are multiple similar characters in the string
then the program displays multiple similar combinations. how could i overcome
this ...comparing each o/p doesn't seem feasible.
 
T

Thomas Matthews

M said:
i have been trying to build a program to find various combinations of a string.
the problem is that if there are multiple similar characters in the string
then the program displays multiple similar combinations. how could i overcome
this ...comparing each o/p doesn't seem feasible.

This is more of a programming issue than a C language issue.
Next time, C language issues are answered in this newsgroup,
general programming issues in
Although your requirements are a bit vague, try creating a
set of all the characters in the string (the set should
allowing only unique characters). Next, generate
combinations of all the letters in the set.

As for duplicate letters, you may want to make the elements
in your set like <letter, quantity>. The quantity will
let you know how many times you can repeat a letter.

As far as repeating goes, you may want to stick in some
advanced rules which filter out unused combinations of
letters, such as "ttt" or "eee". But this depends on
you language.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top