Created
June 7, 2017 05:28
-
-
Save idimiter/8d4a8bc6cbdd91bba745e7afc346ede3 to your computer and use it in GitHub Desktop.
Simple anagram solver
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
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
int main(int ac, char* av[]) { | |
std::vector<std::string> permlist = {"test", "This", "is"}; | |
if (ac > 1) { | |
permlist.clear(); | |
for (int i = 1; i < ac; i++) | |
permlist.push_back(av[i]); | |
} | |
std::sort (permlist.begin() , permlist.end()); | |
do { | |
for (const auto& p : permlist) | |
std::cout << p << ' '; | |
std::cout << std::endl; | |
} while ( std::next_permutation(permlist.begin(), permlist.end()) ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment