#include <iostream>
#include <string>
using namespace std;
// Array with characters
char M[3];
// Function that creates the sequence
void nextChar(char *, int);
int main(){
// Variables
char a, b, c;
cout << "Enter a, b, c with a space\n";
cin >> a >> b >> c;
// Fill the array
M[0] = a;
M[1] = b;
M[2] = c;
// Array storing sequence
char * pt = new char[4];
for(int i = 0; i <= 3; i++)
pt[i] = 0;
// Create a sequence
nextChar(pt, 0);
// Delete array
delete[] pt;
return 0;
}
// Function that creates the sequence
void nextChar(char * pt, int k){
// Loop
for(int i = 0; i < 3; i++)
if(M[i]!=0){
pt[k] = M[i];
M[i] = 0;
if(k + 1 < 3)
nextChar(pt, k + 1);
else{
cout << pt << endl;
}
M[i] = pt[k];
}
}
Comments
Leave a comment