效果如图

代码实现
#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);