// shift.cpp: определяет точку входа для консольного приложения.
//
//#include "stdafx.h"
#include <stdio.h>
#include <string.h>
void reverse(char *arr, int s, int e)
{
char *start = arr + s;
char *end = arr + e - 1;
while (start < end)
{
char c = *start;
*start = *end;
*end = c;
start++;
end--;
}
}
//n - размерность массива
//m - на сколько сдвинуть
void shift(char *arr, int n, int m)
{
reverse(arr, 0, m);
reverse(arr, m, n);
reverse(arr, 0, n);
}
int main()
{
char arr[32];
strcpy(arr, "1234567890");
for (size_t m = 0; m <= strlen(arr); m++, strcpy(arr, "1234567890"))
{
shift(arr, strlen(arr), m);
printf("%s\n", arr);
}
return 0;
}
Ly8gc2hpZnQuY3BwOiDQvtC/0YDQtdC00LXQu9GP0LXRgiDRgtC+0YfQutGDINCy0YXQvtC00LAg0LTQu9GPINC60L7QvdGB0L7Qu9GM0L3QvtCz0L4g0L/RgNC40LvQvtC20LXQvdC40Y8uCi8vCgovLyNpbmNsdWRlICJzdGRhZnguaCIKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCnZvaWQgcmV2ZXJzZShjaGFyICphcnIsIGludCBzLCBpbnQgZSkKewogICAgY2hhciAqc3RhcnQgPSBhcnIgKyBzOwogICAgY2hhciAqZW5kID0gYXJyICsgZSAtIDE7CgogICAgd2hpbGUgKHN0YXJ0IDwgZW5kKQogICAgewogICAgICAgIGNoYXIgYyA9ICpzdGFydDsKICAgICAgICAqc3RhcnQgPSAqZW5kOwogICAgICAgICplbmQgPSBjOwoKICAgICAgICBzdGFydCsrOwogICAgICAgIGVuZC0tOwogICAgfQp9CgovL24gLSDRgNCw0LfQvNC10YDQvdC+0YHRgtGMINC80LDRgdGB0LjQstCwCi8vbSAtINC90LAg0YHQutC+0LvRjNC60L4g0YHQtNCy0LjQvdGD0YLRjAp2b2lkIHNoaWZ0KGNoYXIgKmFyciwgaW50IG4sIGludCBtKQp7CiAgICByZXZlcnNlKGFyciwgMCwgbSk7CiAgICByZXZlcnNlKGFyciwgbSwgbik7CiAgICByZXZlcnNlKGFyciwgMCwgbik7Cn0KCmludCBtYWluKCkKewogICAgY2hhciBhcnJbMzJdOwoKICAgIHN0cmNweShhcnIsICIxMjM0NTY3ODkwIik7CgogICAgZm9yIChzaXplX3QgbSA9IDA7IG0gPD0gc3RybGVuKGFycik7IG0rKywgc3RyY3B5KGFyciwgIjEyMzQ1Njc4OTAiKSkKICAgIHsKICAgICAgICBzaGlmdChhcnIsIHN0cmxlbihhcnIpLCBtKTsKICAgICAgICBwcmludGYoIiVzXG4iLCBhcnIpOwogICAgfQoKICAgIHJldHVybiAwOwp9Cgo=