Код: Выделить всё
int main(){
int n;
cin >> n;
int d;
cin >> d;
int a[1000];
for(int i = 0; i < n; i++){
cin >> a[i];
}
int temp[1000];
for(int i = 0; i < n-d; i++){
temp[i] = a[i];
}
for(int i = 0; i < d; i++){
a[i] = a[n-d+i];
}
for(int i = d; i < n; i++){
a[i] = temp[i-d];
}
for(int i = 0; i < n; i++){
cout n;
int d;
cin >> d;
int a[1000];
for(int i = 0; i < n; i++) {
cin >> a[i];
}
int b[1000];
for(int i = 0; i < n; i++) {
b[i] = a[(i + d) % n];
}
for(int i = 0; i < n; i++) {
cout
для первого < /p>
5
3
1 2 3 4 5
3 4 5 1 2
< /code>
для второго < /p>
5
3
1 2 3 4 5
4 5 1 2 3
Я думаю, что знаю ответ, но просто для подтверждения
Я разговаривал с Chatgpt об этом на пару часов, но кажется, что он пьян
Подробнее здесь: https://stackoverflow.com/questions/796 ... r-rotation
Мобильная версия