473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to print permutations?

If we have three variables a,b,c...which are char variables....th en
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....

May 25 '07 #1
5 1765
On 25 Maj, 14:44, Shraddha <shraddhajosh.. .@gmail.comwrot e:
If we have three variables a,b,c...which are char variables....th en
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....
Perhaps std::next_permu tation() can be of use.

--
Erik Wikström

May 25 '07 #2
"Shraddha" writes:
If we have three variables a,b,c...which are char variables....th en
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....
Use std::next_permu tation() in <algorithm>.
May 25 '07 #3
Shraddha wrote:
If we have three variables a,b,c...which are char variables....th en
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....
Are all of these questions school work or something?
May 25 '07 #4
On May 25, 5:50 pm, Deniz Dogan <kristn...@nosp am.comwrote:
Shraddha wrote:
If we have three variables a,b,c...which are char variables....th en
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....

Are all of these questions school work or something?
Hi Deniz...
This is not a school work...
Actually these permutations are not supposed to be printed mannually.
There is a formula for that permutations... .b'coz of which we can do
that program within 5-7 lines...that works not only for 3 variables
but for n number of characters.
But I am not aware of that formula...so I just want to know that
formula....

May 26 '07 #5
Shraddha wrote:
On May 25, 5:50 pm, Deniz Dogan <kristn...@nosp am.comwrote:
>Shraddha wrote:
>>If we have three variables a,b,c...which are char variables....th en
hoe to print there all permutations?
for example....abc, bac, cab.......all of them....
Are all of these questions school work or something?

Hi Deniz...
This is not a school work...
Actually these permutations are not supposed to be printed mannually.
There is a formula for that permutations... .b'coz of which we can do
that program within 5-7 lines...that works not only for 3 variables
but for n number of characters.
But I am not aware of that formula...so I just want to know that
formula....
http://www.von-oppen.com/doc/cuj/htm...son/nelson.htm

It has the 'formula' you want (actually the algorithm) if you are
prepared to do a little work and actually understand.

john
May 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
5686
by: Steve Goldman | last post by:
Hi, I am trying to come up with a way to develop all n-length permutations of a given list of values. The short function below seems to work, but I can't help thinking there's a better way. Not being a computer scientist, I find recursive functions to be frightening and unnatural. I'd appreciate if anyone can tell me the pythonic idiom to accomplish this. Thanks for your help,
20
2304
by: John Trunek | last post by:
I have a set of X items, but want permutations of length Y (X > Y). I am aware of the permutation functions in <algorithm>, but I don't believe this will do what I want. Is there a way, either through the STL or some other library to do this, or do I need to write my own code?
20
41316
by: anurag | last post by:
hey can anyone help me in writing a code in c (function) that prints all permutations of a string.please help
1
10939
by: JosAH | last post by:
Greetings, last week we talked a bit about generating permutations and I told you that this week will be about combinations. Not true; there's a bit more to tell about permutations and that's what this Tip Of The Week is about. Maybe later we'll talk a bit about combinations (if anyone's interested). The little utility class we implemented last week was able to generate a next permutation (if any) given a current permutation. But what...
5
2697
by: Shraddha | last post by:
Suppose we are having 3 variables...a,b,c And we want to print the permutations of these variables...Such as...abc,acb,bca...all 6 of them... But we are not supposed to do it mannually... I want to know that formula by which this can be possible... Then that program will be ok for nnumber of variables.... Can anyone help me for that?
82
3714
by: Bill Cunningham | last post by:
I don't know if I'll need pointers for this or not. I wants numbers 10^16. Like a credit card 16 digits of possible 10 numbers, so I guess that would be 10^16. So I have int num ; These are of course declared and not initialized. Now I want to initialize them all with '\0'. That I'm guessing would involve while ( --). Or maybe for. Would pointers be involved in this? With this excercise I would learn working with multi-dimensional
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.