博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
猴子选大王(循环单链表)
阅读量:392 次
发布时间:2019-03-05

本文共 611 字,大约阅读时间需要 2 分钟。

 

#include
#include
struct Node{ unsigned long number;//存储某只猴子的编号 struct Node *next;//指向下一猴子结点的指针};struct Node *head;//全局头指针struct Node *start;//全局指针, 表非空时指向表的第一个结点; 否则指向头结点struct Node *rear;//全局尾指针, 表非空时指向表的最后一个结点; 否则指向头结点void create_List()//创建循环链表{ head=(struct Node*)malloc(sizeof(struct Node)); head->number=0;//头结点的数据域存储当前猴子的数量 head->next=head;//表空 start=head; rear=head; return ;}void insert_Elem(unsigned long n)//向链表中插入结点{ struct Node *p; p=(struct Node*)malloc(sizeof(struct Node)); if(head->number==0)//表空 { start=p;//修改开始元素指针 } // p->

转载地址:http://xusg.baihongyu.com/

你可能感兴趣的文章