Created
December 9, 2016 07:12
-
-
Save gavincyi/400577176e69af5e20c122eb308f55d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // you can use includes, for example: | |
| #include <algorithm> | |
| #include <string> | |
| #include <iostream> | |
| using namespace std; | |
| #define vii vector<pair<int, int>> | |
| #define pii pair<int, int> | |
| #define g0( a ) get<0>( a ) | |
| #define g1( a ) get<1>( a ) | |
| void Permutate(string& s, int index) { | |
| if (index == s.size() - 1) { | |
| cout << s << endl; | |
| } else { | |
| for (int i = index; i < s.size(); i++) { | |
| swap(s[index], s[i]); | |
| Permutate(s, index + 1); | |
| swap(s[i], s[index]); | |
| } | |
| } | |
| } | |
| int main() { | |
| auto s = string{"abcd"}; | |
| Permutate(0); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment