diff options
Diffstat (limited to 'introductory_problems/permutations.cpp')
-rw-r--r-- | introductory_problems/permutations.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/introductory_problems/permutations.cpp b/introductory_problems/permutations.cpp new file mode 100644 index 0000000..46d8e79 --- /dev/null +++ b/introductory_problems/permutations.cpp @@ -0,0 +1,18 @@ +// 1070. Permutations +#include <bits/stdc++.h> +using namespace std; + +int main() { + static int num; + scanf("%d", &num); + if (num == 1) + printf("1 "); + else if (num <= 3) + printf("NO SOLUTION\n"); + else { + for (int i = 2; i <= num; i += 2) + printf("%d ", i); + for (int i = 1; i <= num; i += 2) + printf("%d ", i); + } +} |