From 3e8ac7ba4a8f410703aa5a8426f542217adcbf2f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 14 Nov 2025 20:55:42 +0200 Subject: feat(Week07): Add solutions --- Week07/Exercise08.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Week07/Exercise08.cpp (limited to 'Week07/Exercise08.cpp') diff --git a/Week07/Exercise08.cpp b/Week07/Exercise08.cpp new file mode 100644 index 0000000..375d1d4 --- /dev/null +++ b/Week07/Exercise08.cpp @@ -0,0 +1,32 @@ +#include + +void rotate(const unsigned int* input, unsigned int size, unsigned int rotation, unsigned int* output) { + rotation %= size; + + for (unsigned int i = 0; i < size; i++) + output[(i + rotation) % size] = input[i]; +} + +// Никой не е забранил да правим допълнителни функции. +// ВНИМАНИЕ: входния размер ТРЯБВА да бъде константа! +void rotateUserInput(const unsigned int SIZE) { + unsigned int series[SIZE], rotation; + + for (unsigned int i = 0; i < SIZE; i++) + std::cin >> series[i]; + std::cin >> rotation; + + unsigned int result[SIZE]; + rotate(series, SIZE, rotation, result); + + for (unsigned int i = 0; i < SIZE; i++) + std::cout << result[i] << ' '; + std::cout << std::endl; +} + +int main() { + rotateUserInput(6); + rotateUserInput(7); + + return 0; +} -- cgit v1.3.1-23-gd82d