https://ide.codingblocks.com/s/71714
dont know where is the problem
Print no of substring in the string
Hi
Not able to find the question link please post it
i only wanted to print all the substring of the string thats the question please help
you can for that by two for loops
check this piece of code
For(i=0;i<s.length();i++)
{
ans="";
for(j=i;j<s.length();j++)
{
ans=ans+s[j];
cout<<" substring: "<<ans;
}
}
Hit like if you get it!
Cheers!
if i wana do with the help of recursion then please see my code
if you want to do with recursion then the code will be
void solve(string input, string ans,int i)
{
if(i==input.length())
return ;
int j;
for(j=i;j<input.length();j++)
{
ans+=input[j];
cout<<ans<<"\n";
}
ans="";
solve(input,ans,i+1);
}
hit like if you get it!
Cheers!
If you want to do anything by recursion just identify the subproblems and try to solve the subproblems
int above code main subproblem is string from index i to n (i =1 to n)
this is the main logic of solving questions by recursion.
thankyou i will do it .
if your doubt is resolved please mark it resolved in your online course in ask doubt section.