动态队列
#include<bits/stdc++.h>
using namespace std;
string s;
struct node {
int val;
node* next;
};
typedef node* Queue;
typedef node* Node;
int main() {
Queue head=new node;
Node cur = head, nd = NULL;
int n, x;
cin >> n;
while (n--) {
cin >> s;
if (s == "push") {
cin >> x;
nd = new node;
nd->val=x;
nd->next = NULL;
cur->next = nd;
cur = nd;
} else if (s == "pop") {
if (head->next == NULL) {
cout << "error" << endl;
} else {
Node t=head->next;
cout << t->val << endl;
head->next = t->next;
if(t==cur) cur=head;
delete(t);
}
} else if (s == "front") {
if (head->next == NULL) {
cout << "error" << endl;
} else {
cout << head->next->val << endl;
}
}
}
return 0;
}