#include <cstring>
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int temp1 = 0;
char *b, *m;
int temp = 0;
void swap(char *x, char *y)
{
char temp;
temp = *x;
*x = *y;
*y = temp;
}
void permute(char *a, int l, int r, char *b, char *m)
{
int i;
for (i = l; i <= r; i++)
{
for (int j = 0; j <= r; j++) {
swap((a + l), (a + j));
b = m;
while (*b) {
if (*b == 'D') temp = b - m;
if (*b == 'A') temp1 = b - m;
b++;
}
if (temp1 > temp) continue;
cout << a << endl;
}
}
}
int main()
{
char str[] = "ABCDEF";
int n = strlen(str);
b = str;
m = str;
permute(str, 0, n - 1, b, m);
system("pause");
return 0;
}http://www.AssignmentExpert.com/</cstdlib></cstdio></iostream></cstring>
Comments
Dear customer, Unfortunately, your question requires a lot of work and cannot be done for free. Please submit it with all requirements as an assignment to our control panel and we'll assist you.
P(6,4)=360 that means we should get 360 different ways to list all the letters "ABCDEF" were A appears before D. This code just prints 18 outputs !!