Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- //string.substr(int pos,int len)
- //pos = starting poistion of substring
- //len = length of substr required
- //if(len > size of string) then a substr will run until the end of string
- void permutationString(string s,string prefix,string suffix){
- if(prefix.size()==s.size()){
- cout<<prefix<<endl;
- return;
- }else{
- for(int i=0;i<suffix.size();i++){
- permutationString(s,prefix+suffix[i],suffix.substr(0,i)+suffix.substr(i+1,suffix.size()));
- }
- }
- }
- int main(){
- string s = "abc";
- permutationString(s,"",s);
- }
Add Comment
Please, Sign In to add comment