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; } }
0 comments:
Post a Comment