C语言数据结构单链表.docVIP

  • 4
  • 0
  • 约2.16千字
  • 约 4页
  • 2018-11-24 发布于河南
  • 举报
C语言数据结构单链表

单链表的创建,销毁,删除元素,及插入元素 #includestdio.h #includestdlib.h #includemalloc.h struct node { int data; struct node *next; }; struct node *creat()//创建链表 { struct node *p,*q,*head; int i=1; p=head=(struct node *)malloc(sizeof(struct node)); printf(请输入第%d个数字,i); scanf(%d,p-data); head=p; while(p-data!=0i10)//程序编写时为了快速创建链表以检验其他功能,所以设定链表元素为自动输入 { q=(struct node *)malloc(sizeof(struct node)); i++; printf(请输入第%d个数字\n,i); // scanf(%d,q-data); q-data=i; p-next=q; p=q; } p-next=NULL; p=head; while(p!=NULL) { printf(%d\n,p-data); p=p-next; } return head; } struct node *destroy(head

文档评论(0)

1亿VIP精品文档

相关文档