#include <iostream>
using namespace std;
void Move_K(int list[], int K, int N)
{
for (int i = 0, j = K - 1; i < j; i++, j--)
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
for (int i = K, j = N - 1; i < j; i++, j--)
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
for (int i = 0, j = N - 1; i < j; i++, j--)
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
void list_display(int res[], int res_num)
{
cout << "数组打印:" << endl;
for (int i = 0; i < res_num; i++)
{
cout << res[i] << " ";
}
cout << "打印完成!" << endl;
}
int main() {
int list_move[5] = { 1,2,3,4,5 };
int list_num = sizeof(list_move) / sizeof(int);
list_display(list_move, list_num);
Move_K(list_move, 2, list_num);
cout << "move complete!" << endl;
list_display(list_move, list_num);
return 0;
}