chamanchindi

Google

Monday, October 06, 2008

permutaions of the string

Following is the program for printing all the permutations of the given string using same technique. The changes are in print, check and the use of a new String tempStr. Str is the input and tempStr is the string which is used to for recursion. Instead of using ABCD, tempStr consists of characters '0','1','2',..etc. This only for program understading. If '0' is replaced by 'A' in the given program behavior will not change.
So for e.g. tempStr will take values like 0123 and 2301 instead of ABCD and CDAB.

The comments in the program will help to understand the program.

http://rapidshare.com/files/151640585/perm_string.cpp.html

The output of the given program will be

EFGH EFHG EGFH EGHF EHFG EHGF FEGH FEHG
FGEH FGHE FHEG FHGE GEFH GEHF GFEH GFHE
GHEF GHFE HEFG HEGF HFEG HFGE HGEF HGFE
Number of solutions 24

0 Comments:

Post a Comment

<< Home