#includeusing namespace std; typedef struct Node { int data; struct Node *next; }QNode; typedef struct { QNode *front; QNode *rear; }linkQueue; void creatQueue(linkQueue &Q) { Q.front=Q.rear=new QNode; Q.front->next=NULL; return; } bool inQueue(linkQueue &Q,int e) { QNode *cp; cp=new QNode; cp->data=e; cp->next=NULL; Q.rear->next=cp; Q.rear=cp; return true; } int outQueue(linkQueue &Q) { float e; QNode *cp; if(Q.front==Q.rear) return 0; cp=Q.front->next; e=cp->data; Q.front->next=cp->next; if(Q.rear==cp) Q.rear=Q.front; delete cp; return e; } int getQueue(linkQueue Q) { if(Q.front!=Q.rear) return Q.front->next->data; } int lengthQueue(linkQueue Q) { QNode *cp; int i=0; cp=Q.front; while(cp!=Q.rear) { i++; cp=cp->next; } return i; } void ouputQueue(linkQueue Q) { QNode *cp; cp=Q.front->next; while(cp) { cout< data<<" "; cp=cp->next; } cout< >ch; switch(ch) { case 1: creatQueue(Q); cout<<"链队列初始化成功!"< >n; for(a;a<=n;a++) { cout<<"输入入队的第"<>e; inQueue(Q,e); } cout<<"元素输入成功!"< >e; inQueue(Q,e); cout<<"元素填充成功!"< 改代码采用C++进行编译,定义函数进行数据结构中队列的相关操作。



