#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;//结点存放的数据
struct node *next;//指向下一个结点的指针
};
/*建立单链表的函数,返回的是头结点*/
struct node *Create_slist()
{
int x;
struct node *h,*s,*r;
h=(struct node *) malloc(sizeof(struct node));//h为头结点
r=h;
scanf("%d",&x);
while(x!=-1)//输入数据时以-1作为结束标志
{
s=(struct node *)malloc(sizeof(struct node));
s->data=x;
r->next=s;
r
链表的例程
最新推荐文章于 2022-05-09 14:06:28 发布