Website Summary Files Commits Branches @commit @diff @stats
path: root / Week07 / Exercise08.cpp
blob: 375d1d472774f262b8376d54f909e64ea497347f (plain) (blame)
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
#include <iostream>

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;
}