daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top