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