hang doi
typerdef struct queue
{
node*vao,ra
};
struct node
{int x;
node*next;
};
void khoitaohd(queue&Q)
{
Q.vao=null;
Q.ra=null;
}
// them 1 phan tu x vao hd
void them(quenue&Q,int x)
{
node*e;
e=new(node);
e->x=x
e->next=NULl;
if(Q.ra==null)
{
q.ra=e;
q.vao=e;
else
{
q.vao->next=e
e=null
delete(e);
}
//lay 1 phan tu ra khoi hang doi
void pop(int &x,queue&Q)
{
node*tam;
tam=Q.ra;
Q.ra=Q.ra->next
x=tam->x
tam->next=null;
delete(tam);
}
Bạn đang đọc truyện trên: Truyen247.Pro