From 700f2303dfa3307117e8106215c146c419f426cc Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Thu, 19 Dec 2024 20:32:07 -0700 Subject: 1070. permutations --- introductory_problems/permutations.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 introductory_problems/permutations.cpp (limited to 'introductory_problems/permutations.cpp') 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 +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); + } +} -- cgit v1.2.3