Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <sstream>
- #include <algorithm>
- #include <iterator>
- using namespace std;
- void printVector(std::vector<string> vec) {
- copy(vec.begin(), vec.end(), ostream_iterator<string>(cout, " "));
- cout << endl;
- }
- int main() {
- string userinput;
- int counter = 0;
- cout << "Enter text: ";
- getline(cin, userinput);
- stringstream ss(userinput);
- istream_iterator<string> begin(ss);
- istream_iterator<string> end;
- vector<string> vstrings(begin, end);
- cout << endl;
- sort(vstrings.begin(), vstrings.end());
- do {
- printVector(vstrings);
- counter++;
- } while (next_permutation(vstrings.begin(), vstrings.end()));
- cout << endl << counter << " Possible output." << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement