生成输入序列的序列
How to do it...
#include <iostream> #include <vector> #include <string> #include <iterator> #include <algorithm> using namespace std;int main() { vector<string> v {istream_iterator<string>{cin}, {}}; sort(begin(v), end(v));do { copy(begin(v), end(v), ostream_iterator<string>{cout, ", "}); cout << '\n'; } while (next_permutation(begin(v), end(v))); }$ echo "a b c" | ./input_permutations a, b, c, a, c, b, b, a, c, b, c, a, c, a, b, c, b, a,
How it works...
Last updated