why two times ac is getting printed after running the code??
#include
using namespace std;
void subsequence(char *in, char *out, int i, int j)
{
// base case
if (in[i] == ‘\0’)
{
out[j] == ‘\0’;
cout << out << endl;
return;
}
// recursive case
// 1. ignore the ith character
subsequence(in, out, i + 1, j);
// 2. Take the ith character and update the value of j as well as i
out[j] = in[i];
subsequence(in, out, i + 1, j + 1);
}
int main()
{
char in[100];
cin.getline(in, 100);
char out[100];
// cin.getline(out,100);
subsequence(in, out, 0, 0);
return 0;
}