Can anybody help me with permutation in c++. say if the entered string is "stop" then there must be 24 (=4*3*2*1) different words made by the letters s,t,o,p. Similarly if the entered string is "abcde" then there will be 120 (=5*4*3*2*1) different words made using the letters a,b,c,d,e.
Please Help. It`s eating up my head.
varunrathi
0
Light Poster
Recommended Answers
Jump to PostThe STL has a function next_permutation() which you can apply to a vector. This sample code is written for integers, it is your mission to apply your genius to make it work with characters! Report back your success to this illustrious forum!
// permutations of a three …
Jump to PostAny reasonably modern C++ compiler should give you access to the Standard Template Libraries!!!
If Borland Turbo C++ does not provide STL, you do yourself a favor by getting into a more updated version. You can always download the Dev C++ IDE, which uses the open source GCC/G++ compiler, …
Jump to PostActually, the algorithm for the next_permutation() is in the header file called stl_algo.h
Once you installed DevCpp this header file should be in
..\include\C++\3.3.1\bits\Other compilers may have different directories.
Jump to PostTo vegaseat:
I appreciate ur effort to help out varunrathi. However, i think he wanted help with generating permutation(anagrams) of a given word, not to learn how to use STL. I believe if u had given him the pseudo code or the algorithm --that would have helped him more than …
Jump to PostI guess we can all google! Here is in interesting way for character permutations. Check the permutation after the original.
// This program finds permutations using a recursive method // modified Dev C++ from a wonderful article at: //
All 19 Replies
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
varunrathi
0
Light Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
varunrathi
0
Light Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
Asif_NSU
25
Posting Whiz
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
varunrathi
0
Light Poster
varunrathi
0
Light Poster
varunrathi
0
Light Poster
anjaly grace
-7
Newbie Poster
minas1
1
Junior Poster in Training
iamthwee
haroonjamia
-7
Newbie Poster
haroonjamia
-7
Newbie Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
haroonjamia
-7
Newbie Poster
Wader Astra
0
Newbie Poster
richieking
44
Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.