#include<stdio.h>
#include<stdlib.h>
struct link
{
int data;
struct link *next;
};
typedef struct link AA;
AA *creatlist()
{
int c;
AA *h,*r,*s;
h=(AA *)malloc(sizeof(AA));
r=h;
scanf("%d",&c);
while(c!=-1)
{
s=(AA *)malloc(sizeof(AA));
s->data=c;
r->next=s;
r=s;
scanf("%d",&c);
}
r->next=NULL;
return h;
}
void printflist(AA *h)
{
AA *p;
p=h->next;
while(p!=NULL)
{
printf("->%d",p->data);
p=p->next;
}
}
int main()
{
AA *h;
h=creatlist();
printflist(h);
return 0;
}
动态链表的创建
最新推荐文章于 2022-08-31 09:50:56 发布