-1
我只是有一个关于如何打印队列中最后一个元素的快速问题。这是我到目前为止:用尾指针打印节点的键
struct queue {
node * head;
node * tail;
};
void printQ(queue & q) {
node * p = q.head;
cout << "QUEUE: ";
if (q.head == NULL)
cout << "empty";
while (p != NULL)
{
cout << p->key << " ";
p = p->next;
}
cout << " TAIL=" << ?????? // This is where I would like to
get it to print the tail but I'm not
sure how.
谢谢!
如果您尚未打印所有具有该循环的元素,则必须断开您的链接。 – molbdnilo