# 线性表维护(67)

#include <iostream>
#include <string>
using namespace std;

struct st_node
{
string k;
struct st_node * next;
};
typedef struct st_node ptype;
typedef ptype* node;

node root, last, p, back, blast;
string x2, s;
int x1;

{
node q;
if (back->next)
{
q = back->next;
back->next = back->next->next;
}
else
q = new ptype;
q->k = x;
q->next = NULL;
last->next = q;
last = q;
}
void LinearMove(int& x)
{
if (x == 0)
p = root;
else
{
while (x > 0)
{
if (p->next == NULL)
break;
p = p->next;
--x;
}
}

}
void LinearDel(int& x)
{
node q = p;
while (x > 0)
{
q = q->next;
if (q == NULL)
break;
--x;
}
if (back->next == NULL)
blast = back;
blast->next = p->next;
blast = q;
p->next = q->next;
if (q->next == NULL)
last = p;
q->next = NULL;
}

int main()
{
root = new ptype;
root->next = NULL;
p = last = root;

back = new ptype;
back->next = NULL;
blast = back;
while (cin >> s)
{
{
cin >> x2;
}
else if (s == "MOVE")
{
cin >> x1;
LinearMove(x1);
}
else if (s == "DEL")
{
cin >> x1;
LinearDel(x1);
}
else if (s == "PRINT")
{
if (p->next)
cout << p->next->k << endl;
}
else
break;
}
return 0;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120