We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4f2407 commit f3ae205Copy full SHA for f3ae205
next_permutation.cpp
@@ -0,0 +1,30 @@
1
+#include <iostream>
2
+#include <vector>
3
+#include <algorithm> // sort, next_permutation
4
+
5
+using namespace std;
6
7
+int main()
8
+{
9
+ vector<int> myvec = {1,8,4};
10
11
+ sort(myvec.begin(), myvec.end());
12
13
+ do{
14
+ for(int& e : myvec){
15
+ cout << e << " ";
16
+ }
17
+ cout << endl;
18
+ }while(next_permutation(myvec.begin(), myvec.end()));
19
20
+ return 0;
21
+}
22
23
+/*
24
+1 4 8
25
+1 8 4
26
+4 1 8
27
+4 8 1
28
+8 1 4
29
+8 4 1
30
+*/
0 commit comments