#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int a[1001] = { 0 };
for (int i = 1; i < n + 1; i++)
{
a[i] = i;
}
int m;
cin >> m;
int p, q;
for (int i = 0; i < m; i++)
{
cin >> p >> q;
int j;
// 寻找学号p对应的数组下标
// for (j = 1; a[j] != p; j++); // 判断条件至关重要
for (j = 1; j <= n; j++) // 这种判断条件也可以
if (a[j] == p) break; // for (j = 1; a[j] != p; j++);
int pos = j;
// 模拟移动过程
if (q > 0) {
for (int i = pos; i < pos + q; i++)
a[i] = a[i + 1];
a[pos + q] = p;
}
else {
for (int i = pos; i > pos + q; i--)
a[i] = a[i - 1];
a[pos + q] = p;
}
}
for (int i = 1; i < n + 1; i++)
{
cout<<a[i]<<" ";
}
system("pause");
return 0;
}
CCF 201703-2学生排队(100分)
最新推荐文章于 2024-09-07 05:15:02 发布