【发布时间】:2016-01-31 18:39:13
【问题描述】:
我在 C 编程中尝试从队列中删除偶数时卡住了。代码如下:
我的队列数据结构:
typedef struct _listnode
{
int data;
struct _listnode *next;
} ListNode; // You should not change the definition of ListNode
typedef struct _linkedlist
{
int size;
ListNode *first;
} LinkedList; // You should not change the definition of LinkedList
typedef struct _queue
{
LinkedList list;
} Queue;
我是从我的主打来的:
case 3:
deleteEven(&q); // You need to code this function
printf("Result:\n");
printList(&q.list);
break;
首先,我尝试检查队列是否为空。然后我会得到链表头和模数为 2,如果得到 0 意味着它是偶数,然后我会将它从队列中出列。
但是,使用这些代码,当我尝试从队列中取出偶数时,它只是停止工作并且没有显示任何错误消息。
有人知道如何解决这个问题吗?提前致谢。
【问题讨论】:
标签: c pointers linked-list queue nodes