0

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

3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by abhimanipal
0

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...

0
#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 by noobuser: n/a

0

Tell me some thing why are combinations like bcanm allowed ?

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

Edited by abhimanipal: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.