Friday 3 April 2015

write a program to display all possible permutations of a given input string in C++ | How to Find all Possible combination of strings in C++

This Program find the all permutations of string in C++ Program . The Permutations of strings mean all the possible combinations of characters in the string.

Source Code 

#include <iostream>
using namespace std;
/*
 * Uzair
 */
void permutationFunction(void);
int global = 2;

int main()
{
cout<<"Starting Program\n";
permutationFunction();
cout<<"\nProgram Ended";
return 0;
}

void permutationFunction(){
string string;
cout<<"Enter a string of characters to View Permutations\n";
getline(cin, string);
cout<<"\n";
for(int j = 0; j < string.size(); j++)
{
cout << string[j];
for(int k = 0; k < string.size(); k++)
{
if(j != k)
cout << string[k];
}
cout << endl;
}
}

Output of the Program


Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

1 comments: Post Yours! Read Comment Policy!▼
Important Note:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.

  1. What about "acb", "bca", "cba", or "acb"? Rotating a string by a single letter does not give you all of the permutations. If you're going to be posting examples in hopes of teaching others, be sure they are thorough and are actually complete.

    ReplyDelete