I am able the display all the ASCII- subsequences, but not able to print the number of ASCII- subsequences. how can I do that?
code-
#include
#include
using namespace std;
//function to print subsequesnces containg ASCII value of the characters
//or the characters of the given string
void findsub(string str, string res, int i){
//base case
if(i == str.length()){
//if length of the subsequence exceeds 0
if(res.length() > 0){
//print the subsequence
cout << res <<" ";
}
return;
}
//stores character present at the i-th index of str
char ch = str[i];
//if the i-th character is not included in the subsequence
findsub(str, res, i+1);
//icluding the i-th charachter in the subsequence
findsub(str, res + ch, i+1);
//include the ASCII value of the i-th character in the subsequence
findsub(str, res + to_string(int(ch)), i+1);
}
int main(){
string str;
getline(cin,str);
string res ="";
//stores length of str
int N = str.length();
findsub(str, res, 0);
cout<<endl;
return 0;
}