数据结构 线性表的 应用

数据结构 线性表的 应用

ID:11461861

大小:72.00 KB

页数:6页

时间:2018-07-12

数据结构 线性表的 应用_第1页
数据结构 线性表的 应用_第2页
数据结构 线性表的 应用_第3页
数据结构 线性表的 应用_第4页
数据结构 线性表的 应用_第5页
资源描述:

《数据结构 线性表的 应用》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、《数据结构》实验报告实验一、线性表的应用-5-一、实验目的熟练掌握线性表的顺序存储结构和链式存储结构的建立方法以及基本操作算法,并根据实际问题的要求,灵活运用。二、实验内容本次实验要求以班级学生信息作为管理对象,通过实验练习,建立班级学生信息线性表的顺序存储结构和链式存储结构,并练习使用顺序表和单链表的基本操作算法,实现对班级学生信息的管理,包括学生信息的插入、学生信息的删除、学生信息的查询和学生信息线性表的输出。三、完成情况#include"stdio.h"#include"malloc.h"#defineNULL0structstu

2、dent{charname[20];chargender[8];intnum;intscore;structstudent*next;};intn;structstudent*head;structstudent*creat(){structstudent*p,*q;inta;n=0;p=q=(structstudent*)malloc(sizeof(structstudent));printf("请输入学生信息,按学号,姓名,性别,成绩:");scanf("%d%s%s%d",&p->num,p->name,p->gender,&

3、p->score);head=NULL;while(p->num!=0){n+=1;if(n==1)head=p;elseq->next=p;q=p;p=(structstudent*)malloc(sizeof(structstudent));printf("请输入学生信息,按学号,姓名,性别,成绩:");scanf("%d%s%s%d",&p->num,p->name,p->gender,&p->score);}printf("完成,按'1'结束");scanf("%d",&a);if(a){q->next=NULL;ret

4、urn(head);}-5-}voidprint(structstudent*head){inti;structstudent*p;printf("学号(8)姓名(8)性别成绩");printf("-------------------------------------------");printf("学号,姓名,性别,成绩:");p=head;for(i=0;inum,p->name,p->gender,p->sco

5、re);printf("-------------------------------------------");p=p->next;}}voidsearch(structstudent*head,intnumber){structstudent*p;p=head;while(p->num!=number){p=p->next;if(p==NULL)printf("学生信息不存在!");else{printf("该生的信息是:");printf("%d%s%s%d",p->num,p->name,p->gender,p

6、->score);}}}structstudent*insert(structstudent*head,inti){structstudent*p,*q,*r;inta;p=head;r=(structstudent*)malloc(sizeof(structstudent));if(i=n+1){while(p->next!=NULL)p=p->next;p->next=r;r->next=NULL;n+=1;return(head);}elseif(i<=n){for(a=0;anext;q=p-1;q-

7、>next=r;r->next=p;n+=1;printf("完成");return(head);}elseprintf("空间不足!");}-5-structstudent*del(structstudent*head,intnumber){structstudent*p,*q;p=head;while(p->num!=number)p=p->next;if(p==NULL)printf("该生不存在");else{q=p-1;q->next=p->next;free(p);printf("完成");n-=1;return

8、(head);}}voidmain(){inta,sn,dn,location;printf("学生信息管理系统");printf("================================

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。