How to Find all Possible Combinations of Strings in C++

This is the best logic building program for beginners in C++ to understand the function of strings. This Program finds 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 on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment