70,023
社区成员




void in_queue(struct queue *q,char a){
struct node *n=new node;
if(n==NULL){
return;
}
n->data=a;
n->next=NULL;
if(q->rear)
{
q->rear->next=n;
}else{
q->front=n;
}
q->rear=n; // 我刚才漏了这个。
}
void in_queue(struct queue *q,char a){
struct node *n=new node;
if(n==NULL){
return;
}
n->data=a;
n->next=NULL;
if(q->rear)
{
q->rear->next=n;
}else{
q->front=q->rear=n;
}
}
void out_queue(struct queue *q){
struct node * tmp;
if(q->front==NULL)
return;
if(q->front==q->rear)
{
delete q->front;
q->front=q->rear=NULL;
return;
}
tmp=q->front;
q->front=temp->next;
delete tmp;
}
void print(struct queue *q){
struct node *n=q->front;
while(n){
std::cout<< n->data << ' ';
n=n->next;
}
}
粗看了下,你再试试?