Professional Documents
Culture Documents
#include <iostream.h> #include <string.h> #include<conio.h> #include<stdio.h> int k=1; void swap(char* first, char* second) { char ch = *second; *second = *first; *first = ch; }
int permute(char* set, int begin, int end) { int i; int range = end - begin; if (range == 1) { cout <<k<<" "<< set << endl; k++; } else { for(i=0; i<range; i++) { swap(&set[begin], &set[begin+i]); //initial swap
//Example Implementation -- Up to you on how to use int main() { clrscr(); char str[255]; //string cout << "Please enter a string: "; cin.getline(str, 255); //take string permute(str, 0, strlen(str)); //permutate the string getch(); return 0; }