Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void recursive_permutation(string, string);
- void permutations_of_string(string);
- int main() {
- cout << " Password: ";
- string password;
- cin >> password;
- permutations_of_string(password);
- cin.sync();
- cin.get();
- return 0;
- }
- void recursive_permutation(string _so_far, string _rest) {
- if (_rest == "") cout << _so_far << endl;
- else {
- string next, save;
- for (size_t i = 0; i < _rest.size(); i++) {
- next = _so_far + _rest[i];
- save = _rest.substr(0, i) + _rest.substr(i + 1);
- recursive_permutation(next, save);
- }
- }
- }
- void permutations_of_string(string _str) {
- recursive_permutation("", _str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement