1.类型声明
typedef struct CQueue {
struct SLnode* front;
struct SLnode* tail;
}CQueue;
typedef struct SLnode {
int date;
struct SLnode*next;
} SLnode;
2.创造节点
SLnode* BuySLnode() {
SLnode*node = (SLnode*)malloc(sizeof(SLnode));
if(node==NULL)
{
printf("Failed to open up capacity");
}
node->date = 0;
node->next = NULL;
return node;
}
3.类型声明
CQueue* CQueueInit(int k)
{
CQueue*pq= (CQueue*)malloc(sizeof(CQueue));
if (pq == NULL)
{
printf("Failed to open up capacity");
}
SLnode*plist = BuySLnode();
SLnode*p = plist;
for (int i = 0; i < k; i++)
{
p->next = BuySLnode();
p = p->next;
}
p->next = plist;
p = NULL;//不用指针p了置空
pq->front = pq->tail = plist;
return pq;
}