forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestpermutations.cpp
More file actions
40 lines (38 loc) · 950 Bytes
/
Copy pathtestpermutations.cpp
File metadata and controls
40 lines (38 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <permutations.hpp>
#include <vector>
#include <string>
int main() {
using iter::permutations;
std::vector<int> v = {1,2,3};
for (auto vec : permutations(v)) {
for (auto i : vec) {
std::cout << i << " ";
}
std::cout << std::endl;
}
//try with string
std::string s = "aba";
for (auto vec : permutations(s)) {
for (auto c : vec) {
std::cout << c << " ";
}
std::cout << std::endl;
}
s = "abc";
for (auto vec : permutations(s)) {
for (auto c : vec) {
std::cout << c << " ";
}
std::cout << std::endl;
}
std::cout << "init list\n";
//std::next_permutation doesn't work on initializer_lists
for (auto vec : permutations({1,2,3,4})) {
for (auto c : vec) {
std::cout << c << " ";
}
std::cout << std::endl;
}
return 0;
}