Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include<string>
- #include<iostream>
- using namespace std;
- void find(string& input, string cur, int pos, vector<string>&subset)
- {
- if (cur.length())
- subset.push_back(cur);
- if (pos == input.size())
- return;
- for(int i = pos; i < input.length(); i++)
- {
- cur.push_back(input[i]);
- find(input, cur, i+1, subset);
- cur.pop_back();
- }
- }
- vector<string> find_all_subset(string input)
- {
- vector<string> subset;
- find(input, "", 0, subset);
- return subset;
- }
- int main()
- {
- string input = "abcd";
- vector<string> result = find_all_subset(input);
- for (int i =0; i <result.size(); i++)
- cout<<result[i]<< ", "<<endl;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement