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

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;
}

Edited 6 Years Ago by noobuser: n/a

Tell me some thing why are combinations like bcanm allowed ?

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

Edited 6 Years Ago by abhimanipal: n/a

This article has been dead for over six months. Start a new discussion instead.