#include
#include
struct node
{
int data;
struct node *next;
} ;
//create a node
struct node * createNode()
{
struct node *h,*s,*r;
int x;
h = (struct node *)malloc(sizeof(struct node));
printf("Please input number,end by -1");
scanf("%d",&x);
r = h;
while(x!=-1)
{
s = (struct node *)malloc(sizeof(struct node));
r->next = s;
s->data = x;
r = s;
scanf("%d",&x);
}
r->next=NULL;
printf("the line is...\n");
struct node *p;
p = h->next;
while(p!=NULL)
{
printf("%d->",p->data);
p = p->next;
}
return h;
}
// insert a node
void insertNode(struct node *h,int x,int in)
{
int f = 0;
struct node *s;
s = (struct node *)malloc(sizeof(struct node));
s->data = in;
struct n
C语言动态开辟存储空间创建链表
最新推荐文章于 2024-04-18 17:30:22 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)