Hi,

I want to solve a problem( to be honest its my homework )
given two string, the print the permutation in ordered form.

Example:
‫‪Please enter the first string:> abc‬‬
‫‪Please enter the second string:> mn‬‬
‫‪Results will be: abcmn abmnc amnbc mnabc mabcn manbc mabnc ambnc ambcn abmcn‬‬

can anyone help me with the algorithm?

Regards

can anyone please help me!

if you don't know already, daniweb only helps people who show at least some efforts. Just saying "help me please" wont help (and that too for homeworks!!)
First try yourself. Post what you are thinking. If you have managed to write any code so far then post that too.
This will be enough to start with...
Good luck...

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

void func(string generatedtillnow, string first, string second)
{
	if (first == "" && second == "")
	{
		cout << generatedtillnow;
		return;
	}
	if (first == "" && second != "")
	{
		generatedtillnow += second;
		cout << generatedtillnow;
		return;
	}
	if (first != "" && second == "")
	{
		generatedtillnow += first;
		cout << generatedtillnow;
		return;
	}
//	for (j=1,2 if(j=1) func("ab", "c", "mn")
	//	else func(am, bc, n)
	}

int main(void)
{
	string s1 = "abc";
	string s2 = "mn";
	func("", s1, s2);
	return 0;
}

i tried to do something but still no result :|

Tell me some thing why are combinations like bcanm allowed ?

PS: I dont think you have spent any time working on your algorithm

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.