Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. void allsubstrings(string str,int st_index,int end_index, vector<string>& strvector)
  2. {
  3. string st1,st2;
  4. vector<string> tempvector;
  5. vector<string>::iterator it;
  6. if(st_index == end_index)
  7. {
  8. st1.push_back(str[st_index]);
  9. strvector.push_back(st1);
  10. }
  11. else
  12. {
  13. allsubstrings(str,st_index+1,end_index,strvector);
  14. for(it = strvector.begin(); it != strvector.end(); ++it)
  15. {
  16. st2 = *it;
  17. st2 += str[st_index];
  18. tempvector.push_back(st2);
  19. st2.clear();
  20. }
  21. st1.push_back(str[st_index]);
  22. tempvector.push_back(st1);
  23. strvector.insert( strvector.end(), tempvector.begin(), tempvector.end() );
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement