fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string str = "apple";
  7. int n = str.length();
  8. for(int i=0;i<n;i++){
  9. string subst = "";
  10. for(int j=i;j<n;j++){
  11. subst +=str[j];
  12. //Do any operation here , push check for some condition etc
  13. // result.push_back(substr);
  14. cout<<subst<<endl; //not printing why?
  15. }
  16. }
  17. return 0;
  18. }
  19.  
  20.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
a
ap
app
appl
apple
p
pp
ppl
pple
p
pl
ple
l
le
e