#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <string.h>
void permut(string , string);
int main()
{
char pil;
do
{
string s;
printf("PROGRAM PERMUTASI HIMPUNAN\n");
printf("\nInput suatu string : "); cin >> s;
cout << "\nPermutasi dari string " << s << endl;
permut(s," ");
printf("\nAnda Mau mengulangi lagi? ");
scanf("%s",&pil);
}
while(pil=='Y'||pil=='y');
getch();
return 0;
}
int Permute(int n, int r)
{
if ( n < 0 || r < 0 || n < r ) return 0;
}
void permut(string s , string pre=" ")
{
int n = s.length();
if (n==1)
cout << pre + s << endl;
else
for(int i=0; i<n; i++)
{
char temp = s[i];
s[i] = s[0];
s[0] = temp;
permut(s.substr(1,n-1),pre+s.substr(0,1));
}
getch();
}
0 Komentar Terbaik
Post a Comment