(8.4)--8.4 链表的创建和输出.pptVIP

  • 0
  • 0
  • 约1.55千字
  • 约 12页
  • 2024-01-28 发布于陕西
  • 举报

链表的创建和输出

主要内容链表的创建12链表的输出

1链表的创建链表基本操作创建输出插入查找删除

链表的创建在程序执行过程中从无到有地建立起一个链表开辟新结点、输入数据、链接使用动态内存分配malloc函数1链表的创建

例:写一函数建立一个有3名学生数据的单向链表。#includestdio.h#includestdlib.h#defineLENsizeof(structstudent)structstudent{ intnum; floatscore; structstudent*next;};定义结构体类型——结点类型数据域(学号、成绩)用来存放下一个结点的地址1链表的创建

structstudent*creat(){ structstudent*head; structstudent*p1,*p2; head=p1=p2=(structstudent*)malloc(LEN); scanf(%d%f,p1-num,p1-score); 创建第一个结点,指针变量head、p1、p2指向它1链表的创建headp1p210189.5

structstudent*creat(){ while(p1-num!=0) { p1=(structstudent*)ma

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档