(1). 假如队列未满,现有变量data需要入队,请写出表达式;
if( (tail+1)%SEQLEN != head )
{
seqn[tail] = data;
tail = (tail+1)%SEQLEN;
}
(2). 假如队列未空,现在需要从队列取一个元素并赋值给变量data,请写出表达式;
if( head != tail )
{
data = seqn[tail];
head = (head+1)%SEQLEN;
}
(3) 请写出队列为空的判断条件:
if(head == tail)
{
}
(3) 请写出队列满的判断条件:
if( (tail+1) % SEQLEN == head )
{
}
(4) 请写出清空队列的表达式
while(head != tail)
{
(tail+1) % SEQLEN == head
}
(6)请写出计算队列中元素个数的表达式:
(tail - head + SEQLEN) % SEQLEN
(7)队列最多可以存放几个元素:
SEQLEN - 1
----------------------------------------------------------------------------------------------------------------------------
插入到 prev 和 next 中间
new->next = next;
prev->next =new;
删除 prev 和 next中间那个
new = prev->next;
prev->next = new->next;
free(new);
new = NULL;
插入到队尾
new->next = NULL;
head->next = new;
head = head->next;
删除
prev = entry->next;
entry->next = NULL;
free(entry);
entry = NULL;
判断是否为空
head->next = head->prev;