Guest User

Untitled

a guest
Oct 12th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. //string.substr(int pos,int len)
  6. //pos = starting poistion of substring
  7. //len = length of substr required
  8. //if(len > size of string) then a substr will run until the end of string
  9. void permutationString(string s,string prefix,string suffix){
  10. if(prefix.size()==s.size()){
  11. cout<<prefix<<endl;
  12. return;
  13. }else{
  14. for(int i=0;i<suffix.size();i++){
  15.  
  16. permutationString(s,prefix+suffix[i],suffix.substr(0,i)+suffix.substr(i+1,suffix.size()));
  17. }
  18. }
  19. }
  20.  
  21.  
  22.  
  23. int main(){
  24. string s = "abc";
  25. permutationString(s,"",s);
  26.  
  27. }
Add Comment
Please, Sign In to add comment