效果如图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8ff3f2494631971a25348de7e2b4ff56.png)
代码实现
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct CLinkList
{
int data;
struct CLinkList *next;
}node;
void ds_init(node **pNode)
{
int item;
node *temp;
node *target;
printf("输入节点的值,输入0完成初始化\n");
while(1)
{
scanf("%d",&item);
fflush(stdin);
if(item ==0)
return ;
if((*pNode)==NULL)
{
*pNode = (node*)malloc(sizeof(struct CLinkList));
if(!(*pNode))
exit(0);
(*pNode)->data = item;
(*pNode)->next = *pNode;
}
else
{
for(target = (*pNode);target->next != (*pNode); target = target->next);