Computer Science, asked by dashankit1998, 6 months ago

Coding Type Question
Rahul and Rishi decided to plan a word game' The game is in such a way that
each person should give a word to the opposing person and they should come
up with the maximum number of words that can be framed with the given word
Rahul gave one word to Rishi. Your task is to help Rishi to find out the maximum
permutations of a given word​

Answers

Answered by SagarR14
0

Solution for this coding question is in the below file

Attachments:
Answered by ankhidassarma9
1

Answer:

#include <bits/stdc++.h>

using namespace std;

void permut(string a, int p, int r)

{

if (p == r)

 cout<<a<<endl;

else

{

 // For  Permutation

 for (int i = p; i <= r; i++)

 {

  // For Swapping

  swap(a[p], a[i]);

  permut(a, p+1, r);

  swap(a[p], a[i]);

 }

}

}

// Driver Code

int main()

{

string str ;

      cout << "Enter a Word:"<<endl;

cin>>str;

int n = str.size();

cout<<"The maximum possible permutations of the given word​:"  

       <<endl;

permut(str, 0, n-1);

return 0;

}

Explanation:

Output:

Enter a Word:  tap

The permutations of the given word are:

tap

tpa

atp

apt

pat

pta

For more Coding type Questions, click here ->

https://brainly.in/question/7332509

https://brainly.in/question/16088716

Similar questions