#include
using namespace std;
void shift(int *, const size_t, const unsigned, const bool left = true);
void show(int * p, const size_t size);
int main() {
const size_t N = 30;
int a[N];
for (size_t n = 0; n <= N; n++) a[n] = n + 1;
show(a, N);
shift(a, N, 10);
show(a, N);
shift(a, N, 10);
show(a, N);
shift(a, N, 10, false);
show(a, N);
shift(a, N, 10, false);
show(a, N);
cin.get();
return 0;
}
void show(int * p, const size_t size) {
for (size_t k = 0; k < size; k++) cout << p[k] << ' ';
cout << endl;
}
void shift(int * p, const size_t size, const unsigned n, const bool left) {
int temp;
for (unsigned m = 0; m < n; m++) {
if (left) {
temp = p[0];
for (size_t k = 1; k < size; k++) p[k - 1] = p[k];
p[size - 1] = temp;
} else {
temp = p[size - 1];
for (size_t k = size - 1; k > 0; k--)
p[k] = p[k - 1];
p[0] = temp;
}
}
}